Re: question about nullptr

Liste des GroupesRevenir à l c 
Sujet : Re: question about nullptr
De : david.brown (at) *nospam* hesbynett.no (David Brown)
Groupes : comp.lang.c
Date : 09. Jul 2024, 18:19:20
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v6jnu8$1ebr7$1@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14
User-Agent : Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0
On 09/07/2024 14:50, Michael S wrote:
On Tue, 09 Jul 2024 04:32:50 -0700
Tim Rentsch <tr.17687@z991.linuxsc.com> wrote:
 
Michael S <already5chosen@yahoo.com> writes:
>
On Mon, 8 Jul 2024 15:23:47 -0700
"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> wrote:
 
On 7/8/2024 12:28 PM, Michael S wrote:
 
On Sun, 07 Jul 2024 15:17:34 -0700
Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
 
I just about always use NULL, not 0, when I want a null pointer
constant.  Similarly, I use '\0', not 0, when I want a null
character, 0.0 when I want a floating-point zero, and false when
I want a Boolean zero.  I just like being explicit.
>
Pointer:  I very rarely use NULL.
Character:  I never use '\0'.
>
Not even something like:
>
#define CLINE 128
>
char x[CLINE] = { '\0' };
>
?
>
;^)
>
I see nothing special about your case. {0} is the most appropriate.
 
>
Any use of '\0' almost always strikes me as an affectation.  It's
like people want to somehow pretend that it's not the same as
just 0.
>
And, BTW, I never use #define for integer constants.
>
What do you do if you need to define a compile-time constant
whose value is outside the range of signed int?  With the
understanding that the context is C as it is now, and not
C++ or some imagined other language.
 In comment above "integer constant" meant "within the range of signed
int". But let's accept more general meaning. Then, when it happens, I
have a problem and forced to flex my principles :(
Luckily, it's pretty rare. I mean, it's pretty rare that the constant
is both outside the range of signed int and I really really have to
have it as compile-time constant. More often big numbers like these are
used in arithmetic/logic, so 'const wide_type' or 'static const
wide_type' is practically as good as a "real" compile-time constant
despite being "less constant" in theory.
 
static const of the appropriate type should be as good as a define'd value in almost any circumstance (assuming, of course, an optimising compiler).
There are circumstances where you can use an enumeration constant as a named integer constant, but where a static const int value cannot be used, such as the size of statically allocated arrays.  But you are very unlikely to need such a large value to be an integer constant, rather than just a value that the compiler sees as a compile-time constant for optimisation purposes.
(And C23 helpfully allows enum values that are of larger integer types. And also "constexpr" declarations.)

Date Sujet#  Auteur
6 Jul 24 * question about nullptr125Thiago Adams
6 Jul 24 +- Re: question about nullptr1Bonita Montero
6 Jul 24 +- Re: question about nullptr1John McCue
6 Jul 24 +* Re: question about nullptr104Kaz Kylheku
6 Jul 24 i+* Re: question about nullptr86Janis Papanagnou
6 Jul 24 ii+* Re: question about nullptr2Janis Papanagnou
6 Jul 24 iii`- Re: question about nullptr1Janis Papanagnou
6 Jul 24 ii+* Re: question about nullptr2Andrey Tarasevich
7 Jul 24 iii`- Re: question about nullptr1Tim Rentsch
6 Jul 24 ii+* Re: question about nullptr2bart
7 Jul 24 iii`- Re: question about nullptr1Keith Thompson
6 Jul 24 ii+* Re: question about nullptr9Chris M. Thomasson
6 Jul 24 iii+* Re: question about nullptr3Chris M. Thomasson
7 Jul 24 iiii`* Re: question about nullptr2Lawrence D'Oliveiro
9 Jul 24 iiii `- Re: question about nullptr1Chris M. Thomasson
6 Jul 24 iii+- Re: question about nullptr1Richard Damon
7 Jul 24 iii+* Re: question about nullptr3James Kuyper
7 Jul 24 iiii`* Re: question about nullptr2Keith Thompson
7 Jul 24 iiii `- Re: question about nullptr1Chris M. Thomasson
7 Jul 24 iii`- Re: question about nullptr1Lawrence D'Oliveiro
7 Jul 24 ii+- Re: question about nullptr1Kaz Kylheku
7 Jul 24 ii`* Re: question about nullptr69Ben Bacarisse
7 Jul 24 ii +- Re: question about nullptr1Tim Rentsch
7 Jul 24 ii +- Re: question about nullptr1Tim Rentsch
7 Jul 24 ii +- Re: question about nullptr1Kaz Kylheku
7 Jul 24 ii `* Re: question about nullptr65Ben Bacarisse
8 Jul 24 ii  +* Re: question about nullptr37Keith Thompson
8 Jul 24 ii  i+- Re: question about nullptr1Janis Papanagnou
8 Jul 24 ii  i+* Re: question about nullptr27Michael S
9 Jul 24 ii  ii+* Re: question about nullptr12Chris M. Thomasson
9 Jul 24 ii  iii`* Re: question about nullptr11Michael S
9 Jul 24 ii  iii `* Re: question about nullptr10Tim Rentsch
9 Jul 24 ii  iii  +* Re: question about nullptr6Thiago Adams
9 Jul 24 ii  iii  i+* Re: question about nullptr3Tim Rentsch
9 Jul 24 ii  iii  ii`* Re: question about nullptr2Thiago Adams
9 Jul 24 ii  iii  ii `- Re: question about nullptr1Tim Rentsch
10 Jul 24 ii  iii  i`* Re: question about nullptr2Kaz Kylheku
10 Jul 24 ii  iii  i `- Re: question about nullptr1Thiago Adams
9 Jul 24 ii  iii  `* Re: question about nullptr3Michael S
9 Jul 24 ii  iii   +- Re: question about nullptr1Tim Rentsch
9 Jul 24 ii  iii   `- Re: question about nullptr1David Brown
9 Jul 24 ii  ii+* Re: question about nullptr4Kaz Kylheku
9 Jul 24 ii  iii`* Re: question about nullptr3Michael S
9 Jul 24 ii  iii +- Re: question about nullptr1Kaz Kylheku
9 Jul 24 ii  iii `- Re: question about nullptr1Tim Rentsch
9 Jul 24 ii  ii`* Re: question about nullptr10Tim Rentsch
9 Jul 24 ii  ii `* Re: question about nullptr9Keith Thompson
9 Jul 24 ii  ii  +- Re: question about nullptr1Chris M. Thomasson
10 Jul 24 ii  ii  `* Re: question about nullptr7Tim Rentsch
10 Jul 24 ii  ii   `* Re: question about nullptr6Keith Thompson
11 Jul 24 ii  ii    +* Re: question about nullptr3James Kuyper
13 Aug 24 ii  ii    i`* Re: question about nullptr2Tim Rentsch
13 Aug 24 ii  ii    i `- Re: question about nullptr1Keith Thompson
13 Aug 24 ii  ii    `* Re: question about nullptr2Tim Rentsch
13 Aug 24 ii  ii     `- Re: question about nullptr1Keith Thompson
8 Jul 24 ii  i+- Re: question about nullptr1Keith Thompson
9 Jul 24 ii  i`* Re: question about nullptr7Andrey Tarasevich
9 Jul 24 ii  i +* Re: question about nullptr2Andrey Tarasevich
11 Jul 24 ii  i i`- Re: question about nullptr1Lawrence D'Oliveiro
9 Jul 24 ii  i `* Re: question about nullptr4Keith Thompson
10 Jul 24 ii  i  `* Re: question about nullptr3Tim Rentsch
10 Jul 24 ii  i   `* Re: question about nullptr2Keith Thompson
12 Aug 24 ii  i    `- Re: question about nullptr1Tim Rentsch
8 Jul 24 ii  `* Re: question about nullptr27Ben Bacarisse
8 Jul 24 ii   +* Re: question about nullptr24Kaz Kylheku
8 Jul 24 ii   i+* Re: question about nullptr22Janis Papanagnou
8 Jul 24 ii   ii+* Re: question about nullptr19Ben Bacarisse
8 Jul 24 ii   iii+* Re: question about nullptr12Janis Papanagnou
8 Jul 24 ii   iiii`* Re: question about nullptr11Ben Bacarisse
8 Jul 24 ii   iiii `* Re: question about nullptr10Janis Papanagnou
9 Jul 24 ii   iiii  `* Re: question about nullptr9Ben Bacarisse
10 Jul 24 ii   iiii   `* Re: question about nullptr8Janis Papanagnou
11 Jul 24 ii   iiii    `* Re: question about nullptr7Ben Bacarisse
12 Jul 24 ii   iiii     `* Re: question about nullptr6Janis Papanagnou
13 Jul 24 ii   iiii      +* Re: question about nullptr3Ben Bacarisse
13 Jul 24 ii   iiii      i`* Re: question about nullptr2Janis Papanagnou
15 Jul 24 ii   iiii      i `- Re: question about nullptr1Ben Bacarisse
13 Jul 24 ii   iiii      +- Re: question about nullptr1Janis Papanagnou
17 Jul 24 ii   iiii      `- Re: question about nullptr1Tim Rentsch
9 Jul 24 ii   iii`* Re: question about nullptr6Kaz Kylheku
9 Jul 24 ii   iii +- Re: question about nullptr1Chris M. Thomasson
9 Jul 24 ii   iii `* Re: question about nullptr4Ben Bacarisse
11 Jul 24 ii   iii  `* Re: question about nullptr3Chris M. Thomasson
11 Jul 24 ii   iii   `* Re: question about nullptr2Ben Bacarisse
11 Jul 24 ii   iii    `- Re: question about nullptr1Chris M. Thomasson
11 Jul 24 ii   ii`* Re: question about nullptr2Lawrence D'Oliveiro
12 Jul 24 ii   ii `- Re: question about nullptr1Janis Papanagnou
8 Jul 24 ii   i`- Re: question about nullptr1Richard Damon
8 Jul 24 ii   `* Re: question about nullptr2James Kuyper
9 Jul 24 ii    `- Re: question about nullptr1Kaz Kylheku
6 Jul 24 i+* Re: question about nullptr4bart
7 Jul 24 ii`* Re: question about nullptr3Lawrence D'Oliveiro
7 Jul 24 ii +- Re: question about nullptr1Keith Thompson
7 Jul 24 ii `- Re: question about nullptr1bart
12 Jul 24 i`* Re: question about nullptr13Richard Harnden
12 Jul 24 i +* Re: question about nullptr4Kaz Kylheku
13 Jul 24 i i`* Re: question about nullptr3Kaz Kylheku
13 Jul 24 i i +- Re: question about nullptr1James Kuyper
13 Jul 24 i i `- Re: question about nullptr1Keith Thompson
14 Jul 24 i +- Re: question about nullptr1Tim Rentsch
16 Jul 24 i `* Re: question about nullptr7Lawrence D'Oliveiro
6 Jul 24 `* Re: question about nullptr18Richard Damon

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal