[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Patch] CVS-Guile compilation problems
From: |
Dirk Herrmann |
Subject: |
Re: [Patch] CVS-Guile compilation problems |
Date: |
Thu, 15 Feb 2001 22:51:30 +0100 (MET) |
On 15 Feb 2001, Matthias Koeppe wrote:
> Marius Vollmer <address@hidden> writes:
>
> > Would it suffice to just use this?
> >
> > next_symbol:
> > ;
> > }
> >
> > "(void)0" looks strange.
>
> I don't think that a singleton ";" is a C statement. That's why one
> has to write `do { ... } while (0)' in all these preprocessor macros
> -- just to avoid a singleton ";".
I found the following in "N843, the official committee document" at
http://www.dkuug.dk/JTC1/SC22/WG14/www/docs/n843.htm.
[#3] A null statement (consisting of just a semicolon)
performs no operations.
[... example deleted]
[#5] EXAMPLE 2 In the program fragment
char *s;
/* ... */
while (*s++ != '\0')
;
a null statement is used to supply an empty loop body to the
iteration statement.
[#6] EXAMPLE 3 A null statement may also be used to carry a
label just before the closing } of a compound statement.
while (loop1) {
/* ... */
while (loop2) {
/* ... */
if (want_out)
goto end_loop1;
/* ... */
}
/* ... */
end_loop1: ;
}
Thus, using a ";" as a no-op statement should be alright (or has the
definition changed from the old C standard?). Probably there are other
reasons why many macros use the "do {...} while (0)" wrapper?
Thus, except someone can prove that ";" is not allowed in the current C
standard, I would prefer the ";" solution over the "(void)0;"
Best regards,
Dirk Herrmann