Re: Concatenated if and preprocessor

Liste des GroupesRevenir à cl c 
Sujet : Re: Concatenated if and preprocessor
De : david.brown (at) *nospam* hesbynett.no (David Brown)
Groupes : comp.lang.c
Date : 15. Mar 2025, 17:32:32
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vr4a30$3qgtf$2@dont-email.me>
References : 1 2 3 4 5 6 7 8
User-Agent : Mozilla Thunderbird
On 14/03/2025 23:29, Tim Rentsch wrote:
Richard Harnden <richard.nospam@gmail.invalid> writes:
 
On 14/03/2025 21:10, Keith Thompson wrote:
>
Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
>
Richard Harnden <richard.nospam@gmail.invalid> writes:
>
On 14/03/2025 16:44, Tim Rentsch wrote:
>
     for(  int just_once = 1;  just_once;  just_once = 0  ){
>
Any reason not to say ...
>
do {
      ...
} while (0);
>
... ?
>
In fact using do/while(0) is what I first wrote.  But then
I thought, oh wait, what if an overzealous compiler gives
a warning because the while() expression is always false? :-/
>
That would break a lot of macros :)
>
[...]
>
Hmm, clang with -Weverything is okay with:
   do { ... } while (0);
>
But not with:
   if ( 0 ) { ... }
>
But it's okay with:
   if ( (0) ) { ... }
 These examples illustrate why I have the reaction I do.  That
plus the lack of clarity as to what the OP's actual requirements
are explains my decision to use a for() rather than do/while(0).
I think your "for" solution would raise far more questions to any reader than idiomatic "do ... while (0)" would, or even if ((0)).  I really don't understand your reactions at all.
But I fully agree that it would be a lot easier to give the OP a good answer if he explained his requirements and situation better.

Date Sujet#  Auteur
13 Mar 25 * Concatenated if and preprocessor26pozz
13 Mar 25 +- Re: Concatenated if and preprocessor1David Brown
13 Mar 25 +- Re: Concatenated if and preprocessor1James Kuyper
13 Mar 25 +- Re: Concatenated if and preprocessor1Kaz Kylheku
13 Mar 25 +- Re: Concatenated if and preprocessor1bart
13 Mar 25 +* Re: Concatenated if and preprocessor3Tim Rentsch
14 Mar 25 i`* Re: Concatenated if and preprocessor2Lynn McGuire
14 Mar 25 i `- Re: Concatenated if and preprocessor1Tim Rentsch
13 Mar 25 +- Re: Concatenated if and preprocessor1James Kuyper
14 Mar 25 `* Re: Concatenated if and preprocessor17pozz
14 Mar 25  +- Re: Concatenated if and preprocessor1David Brown
14 Mar 25  +- Re: Concatenated if and preprocessor1Dan Purgert
14 Mar 25  +* Re: Concatenated if and preprocessor12Tim Rentsch
14 Mar 25  i`* Re: Concatenated if and preprocessor11Richard Harnden
14 Mar 25  i +* Re: Concatenated if and preprocessor9Tim Rentsch
14 Mar 25  i i`* Re: Concatenated if and preprocessor8Keith Thompson
14 Mar 25  i i +* Re: Concatenated if and preprocessor3Richard Harnden
14 Mar 25  i i i`* Re: Concatenated if and preprocessor2Tim Rentsch
15 Mar 25  i i i `- Re: Concatenated if and preprocessor1David Brown
14 Mar 25  i i +* Re: Concatenated if and preprocessor3Tim Rentsch
15 Mar 25  i i i`* Re: Concatenated if and preprocessor2Keith Thompson
15 Mar 25  i i i `- Re: Concatenated if and preprocessor1Tim Rentsch
15 Mar 25  i i `- Re: Concatenated if and preprocessor1David Brown
15 Mar 25  i `- Re: Concatenated if and preprocessor1Lawrence D'Oliveiro
14 Mar 25  +- Re: Concatenated if and preprocessor1Keith Thompson
15 Mar 25  `- Re: Concatenated if and preprocessor1James Kuyper

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal