inconsistent macro behavior
Jay
jayk123@hotmail.com
Mon Jul 28 08:41:00 GMT 2008
--Forwarded Message Attachment--
> Date: Sun, 27 Jul 2008 20:24:57 -0700
> ext@sidvind.com
> [R] reza@parvan.net
> To: gcc-help@gcc.gnu.org
> Subject: inconsistent macro behavior
[R] ...
[R] #define x "llll
[R] #define y "
[R] ...
Search the web for "preprocessor tokenization".
The preprocessor is a bit strange. It resembles:
- spec the existing (at the time) implementation(s)
- spec something that is "reasonable" for "reasonable" "interesting' input
- for input that is NOT "reasonable" and/or "interesting", favor existing implementation(s), even IF it doesn't make much sense
- for input that IS "reasonable" and/or "interesting", walk a tightrope between existing implementation(s) and making sense, not always possible to do both, but often
As well, the C/C++ preprocessor is often used against other than C/C++ code, but it wasn't really designed for such, and doesn't always work well.
Microsoft Visual C++ does not like it either:
D:\Documents and Settings\jay>type 5.c
#define x "llll
#define y "
D:\Documents and Settings\jay>cl -c 5.c
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.762 for 80x86
5.c
5.c(1) : error C2001: newline in constant
5.c(2) : error C2001: newline in constant
D:\Documents and Settings\jay>cl -c -E 5.c
5.c
#line 1 "5.c"
5.c(1) : error C2001: newline in constant
5.c(2) : error C2001: newline in constant
- Jay
More information about the Gcc-help
mailing list