Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #142256
| Newsgroups | comp.lang.c |
|---|---|
| Date | 2019-03-22 12:14 -0700 |
| References | <889cb53d-0093-4df2-8cb6-9717f07c4145@googlegroups.com> |
| Message-ID | <96bb97ca-866f-4bb9-8105-c837efbdf5b6@googlegroups.com> (permalink) |
| Subject | Re: nullptr in C |
| From | Thiago Adams <thiago.adams@gmail.com> |
On Wednesday, August 22, 2018 at 9:53:12 AM UTC-3, Thiago Adams wrote: > Considering nullptr is a keyword in C++ and considering > many people (including me) try to keep the C code compiling > in C++ should we adopt it as a macro in C? > > I can see some similarities with bool in C. > > When I include: > > #include <stdbool.h> > > the code works with bool , true , false in C and C++. > > So.. I was thinking in > > #include <stdnull.h> > > and create nullptr macro if the code is comping in C. > > The other option could be define NULL as nullptr if the > compiler is C++ and use NULL everywhere. > > Have you ever make this question to yourself? > What to do? I changed my mind and I don't think adding nullptr is a good idea. One difference between adding _Bool into the language is that BOOL was never added into the language headers. (Am I right? I didn't find BOOL or TRUE FALSE at the language specification). On the other hand if you search for NULL at the standard you will find that NULL is defined in stddef.h This means that adding _Bool didn't added a new way to declare booleans, but adding nullptr will create this confusion that is two ways of writing code that means NULL. In C we also have different ((void*)0) conversion rules compared with C++ that is more strict. Then for C, I believe that the literal that corresponds nullptr already exists and it is ((void*)0). What could be done is adding flags to static analysis to decide what to do with ((void*)0) conversions.
Back to comp.lang.c | Previous | Next — Next in thread | Find similar | Unroll thread
Re: nullptr in C Thiago Adams <thiago.adams@gmail.com> - 2019-03-22 12:14 -0700
Re: nullptr in C James Kuyper <jameskuyper@alumni.caltech.edu> - 2019-03-22 13:29 -0700
Re: nullptr in C Thiago Adams <thiago.adams@gmail.com> - 2019-03-24 04:51 -0700
Re: nullptr in C William Ahern <william@25thandClement.com> - 2019-03-25 06:50 -0700
Re: nullptr in C James Kuyper <jameskuyper@alumni.caltech.edu> - 2019-03-25 11:37 -0700
Re: nullptr in C Thiago Adams <thiago.adams@gmail.com> - 2019-03-25 12:01 -0700
Re: nullptr in C James Kuyper <jameskuyper@alumni.caltech.edu> - 2019-03-25 12:23 -0700
Re: nullptr in C Ian Collins <ian-news@hotmail.com> - 2019-03-26 08:33 +1300
Re: nullptr in C James Kuyper <jameskuyper@alumni.caltech.edu> - 2019-03-25 12:58 -0700
Re: nullptr in C Ian Collins <ian-news@hotmail.com> - 2019-03-26 10:25 +1300
Re: nullptr in C Keith Thompson <kst-u@mib.org> - 2019-03-25 13:15 -0700
Re: nullptr in C James Kuyper <jameskuyper@alumni.caltech.edu> - 2019-03-25 13:21 -0700
csiph-web