[PPL-devel] Behaviors of `gcc -E -C'

Roberto Bagnara bagnara at cs.unipr.it
Mon Oct 8 10:34:06 CEST 2001


Hi there,

here is a problem I have encountered that may be of interest to both
the GCC and the DOXYGEN communities.
Consider the following 4 non-empty lines of C text:

#if 0
/* I would like not to see this. */
int x;
#endif

Put these 4 lines into a file called foo.c and then
try

    gcc -E -P -C foo.c

Here is the behavior I observe with different (official and unofficial)
versions of gcc:

egcs-2.91.66 (kgcc)  produces a blank line
egcs-2.95.3          produces a blank line
gcc 2.96-85 (RedHat) produces the comment I would like not to see
gcc 3.0.1            produces the comment I would like not to see
gcc 3.1 20011006     prints nothing (GOOD!)

This issue is quite relevant if one uses doxygen
(http://www.doxygen.org/), since there comments are relevant (whence
the use of `-C').  A situation where the behavior of gcc 2.96-85 and
gcc 3.0.1 may byte you is the following:

#if 0
/*! A comment referring to x. */
int x;
#endif
int y;

Doxygen uses special comments like the above (notice the exclamation
mark) for documentation.  When using doxygen is fed with text coming
from the GCC preprocessor, gcc 2.96-85 (RedHat) and gcc 3.0.1
cause a comment for (disregarded) x to be applied to y.
There are other tools that look inside comments to derive useful
information: these are also affected as well.

I wrote this message because I believe it is important not to
overlook the issue.  I have quickly checked the standard documents,
but I have not found anything that prescribes the behavior
that I consider "desirable".  I have also checked the documentation
of the `-C' option but this is also somewhat ambiguous on the subject.

A last question: even though the CVS HEAD version is OK
(for my purposes, at least), what will gcc 3.0.2 do?
All the best,

    Roberto

-- 
Roberto Bagnara
Computer Science Group
Department of Mathematics, University of Parma, Italy
http://www.cs.unipr.it/~bagnara/
mailto:bagnara at cs.unipr.it



More information about the PPL-devel mailing list