RE: inconsistent macro behavior

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



  --Forwarded Message Attachment--
 >  Date: Sun, 27 Jul 2008 20:24:57 -0700
 >  ext@xxxxxxxxxxx
 >  [R] reza@xxxxxxxxxx
 >  To: gcc-help@xxxxxxxxxxx
 >  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


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux