This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
macro expansion
- From: Matti Linsu <matti dot linsu at yahoo dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Tue, 31 Aug 2010 11:04:04 -0700 (PDT)
- Subject: macro expansion
Hi,
I have been playing around with gcc Pre-Processor and I cannot explain one
behavior.
The code bellow demonstrate my question.
Input file :
---------------------------------------
#define START_WITH_A_NUMBER 0_start_with_a_number
#define START_WITH_A_LETTER a_start_with_a_letter
#define I_LOVE_SPACE I love space
START_WITH_A_NUMBER+0
START_WITH_A_LETTER+0
I_LOVE_SPACE
---------------------------------------
Pre-processed output (gcc -E -P myfile):
---------------------------------------
0_start_with_a_number +0
a_start_with_a_letter+0
I love space
---------------------------------------
1) Why is there a space after '0_start_with_a_number' whereas no space is
present after 'a_start_with_a_letter'?
2) Why does gcc remove the spaces inside the replacement list of I_LOVE_SPACE?
3) Does it serve a purpose?
4) Is there a PP flag to force gcc to pre-process by the standard?
Thanks
Matti
P.S:
- gcc version 3.4.5 (mingw-vista special r3)
- '16.3 Macro replacement' chapter from a C++ spec did not help me to understand
gcc behavior.