Groups | Search | Server Info | Keyboard shortcuts | Login | Register
Groups > comp.lang.c > #391206
| From | Tim Rentsch <tr.17687@z991.linuxsc.com> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Concatenated if and preprocessor |
| Date | 2025-03-14 15:29 -0700 |
| Organization | A noiseless patient Spider |
| Message-ID | <867c4rs0tr.fsf@linuxsc.com> (permalink) |
| References | (2 earlier) <86frjfsgtb.fsf@linuxsc.com> <vr1rni$1q6m7$1@dont-email.me> <86bju3s5vp.fsf@linuxsc.com> <87zfhniaij.fsf@nosuchdomain.example.com> <vr276s$2307i$1@dont-email.me> |
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).
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar
Concatenated if and preprocessor pozz <pozzugno@gmail.com> - 2025-03-13 16:44 +0100
Re: Concatenated if and preprocessor David Brown <david.brown@hesbynett.no> - 2025-03-13 16:55 +0100
Re: Concatenated if and preprocessor scott@slp53.sl.home (Scott Lurndal) - 2025-03-13 16:11 +0000
Re: Concatenated if and preprocessor James Kuyper <jameskuyper@alumni.caltech.edu> - 2025-03-13 12:07 -0400
Re: Concatenated if and preprocessor Kaz Kylheku <643-408-1753@kylheku.com> - 2025-03-13 16:30 +0000
Re: Concatenated if and preprocessor bart <bc@freeuk.com> - 2025-03-13 17:29 +0000
Re: Concatenated if and preprocessor Tim Rentsch <tr.17687@z991.linuxsc.com> - 2025-03-13 14:37 -0700
Re: Concatenated if and preprocessor Lynn McGuire <lynnmcguire5@gmail.com> - 2025-03-13 18:25 -0500
Re: Concatenated if and preprocessor Tim Rentsch <tr.17687@z991.linuxsc.com> - 2025-03-14 09:26 -0700
Re: Concatenated if and preprocessor James Kuyper <jameskuyper@alumni.caltech.edu> - 2025-03-13 12:19 -0400
Re: Concatenated if and preprocessor pozz <pozzugno@gmail.com> - 2025-03-14 13:02 +0100
Re: Concatenated if and preprocessor David Brown <david.brown@hesbynett.no> - 2025-03-14 14:13 +0100
Re: Concatenated if and preprocessor Dan Purgert <dan@djph.net> - 2025-03-14 13:44 +0000
Re: Concatenated if and preprocessor Tim Rentsch <tr.17687@z991.linuxsc.com> - 2025-03-14 09:44 -0700
Re: Concatenated if and preprocessor Richard Harnden <richard.nospam@gmail.invalid> - 2025-03-14 18:15 +0000
Re: Concatenated if and preprocessor Tim Rentsch <tr.17687@z991.linuxsc.com> - 2025-03-14 13:40 -0700
Re: Concatenated if and preprocessor Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2025-03-14 14:10 -0700
Re: Concatenated if and preprocessor Richard Harnden <richard.nospam@gmail.invalid> - 2025-03-14 21:31 +0000
Re: Concatenated if and preprocessor Tim Rentsch <tr.17687@z991.linuxsc.com> - 2025-03-14 15:29 -0700
Re: Concatenated if and preprocessor David Brown <david.brown@hesbynett.no> - 2025-03-15 17:32 +0100
Re: Concatenated if and preprocessor Tim Rentsch <tr.17687@z991.linuxsc.com> - 2025-03-14 15:57 -0700
Re: Concatenated if and preprocessor Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2025-03-14 16:27 -0700
Re: Concatenated if and preprocessor scott@slp53.sl.home (Scott Lurndal) - 2025-03-15 15:06 +0000
Re: Concatenated if and preprocessor Tim Rentsch <tr.17687@z991.linuxsc.com> - 2025-03-15 08:49 -0700
Re: Concatenated if and preprocessor scott@slp53.sl.home (Scott Lurndal) - 2025-03-15 17:28 +0000
Re: Concatenated if and preprocessor David Brown <david.brown@hesbynett.no> - 2025-03-15 17:28 +0100
Re: Concatenated if and preprocessor Lawrence D'Oliveiro <ldo@nz.invalid> - 2025-03-15 07:03 +0000
Re: Concatenated if and preprocessor Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2025-03-14 11:10 -0700
Re: Concatenated if and preprocessor James Kuyper <jameskuyper@alumni.caltech.edu> - 2025-03-14 23:20 -0400
csiph-web