This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
3.1 preprocessor regression?
- From: jtc at acorntoolworks dot com (J.T. Conklin)
- To: gcc at gcc dot gnu dot org
- Date: 16 May 2002 17:48:46 -0700
- Subject: 3.1 preprocessor regression?
- Reply-to: jtc at acorntoolworks dot com
This code:
#define anglequote(x) < ## x ## >
#include anglequote(stdio.h)
Worked with gcc 2.95.3 but fails with gcc 3.1 like:
$ gcc -c foo.c
foo.c:2:28: missing terminating > character
foo.c:2:29: stdio: no such file or directory
If I remove the #include keyword and then run the file through the
preprocessor, I get:
foo.c:2:19: warning: pasting "<" and "stdio" does not give a valid preprocessing token
foo.c:2:19: warning: pasting "h" and ">" does not give a valid preprocessing token
I read the preprocessor section of the C9X standard, and I think what
I want to do is valid. As I read 6.10.3.3, when the anglequote macro
is expanded, both ## operators should be replaced before the macro is
rexamined for further expansion. So it shouldn't matter that "<stdio"
and "h>" are not valid preprocessor tokens, as <stdio.h> is. Perhaps
I'm all wet though. Knowing that would be useful too...
The anglequote macro is actually a cut down version of a set of macros
from some code I recently ran across that slices together header-names
to include based on the settings of various macros.
Thanks,
--jtc
--
J.T. Conklin