Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #142408

Re: nullptr in C

Message-ID <6u2nmf-71k.ln1@wilbur.25thandClement.com> (permalink)
From William Ahern <william@25thandClement.com>
Subject Re: nullptr in C
Newsgroups comp.lang.c
References <889cb53d-0093-4df2-8cb6-9717f07c4145@googlegroups.com> <96bb97ca-866f-4bb9-8105-c837efbdf5b6@googlegroups.com> <4d7e3b50-08f1-460d-8c87-3b116a7bc906@googlegroups.com> <8e0e9586-6759-4570-9f5d-dfe3b9f7844b@googlegroups.com>
Date 2019-03-25 06:50 -0700

Show all headers | View raw


Thiago Adams <thiago.adams@gmail.com> wrote:
> On Friday, March 22, 2019 at 5:29:35 PM UTC-3, James Kuyper wrote:
<snip>
>> Actually, C has two ways to declare booleans, both of which were added to
>> the language at the same time: _Bool and bool.
> 
> Yes, I was discarding the direct use of _Bool in my mind.
> Does anyone uses _Bool instead of bool ?

I use _Bool to avoid ambiguity and potential correctness issues for when a
header is compiled with C++.

I also prefer _Static_assert over static_assert after encountering an issue
between a glibc <assert.h> header and GCC versions. (I forget whether the
issue was an old glibc and new GCC or new glibc and old GCC.)

> Thinking in this way, if we had _Null we could leave 
> it just to implement NULL and not use it directly, but I 
> cannot see other advantages over ((void*)0). Like you said
> C doesn't have the same needs of C++.
> 
> What worries me is the mess caused by may types of styles
> inside the same source code. I think many companies using
> C++ are facing these questions of style.

The magnitude of consistency issues in C++ is simply incomparable to C.

Using _Bool over bool is mostly an aesthetic issue that one can get over
very quickly. While there may be good reasons for using one over the other,
those reasons mostly implicate language interoperability issues and don't
reflect substantive C language complexity (e.g. not an example of TMTOWTDI).
Someone doesn't need to understand why one was chosen over the other--as far
as C is concerned they have identical behavior, and that's the end of it.

Indeed, _Bool vs bool, _Static_assert vs static_assert, etc, are more
reflective of C++ or C/C++ interoperability than of C, per se.

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


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