line continuation problem
Jack G Zhang
jackgzhang@hotmail.com
Tue Jun 17 01:49:00 GMT 2003
Hi Folks,
I have following questions need your help.
For GCC 2.95.3, when the compiler see a white space after the line
continuation character '\' it will give errors. In GCC3 this will be an
warning. What I need to to is tweak GCC2.95.3 and add this feature.
Following is the sample code: (There is an whitespace at the end of '\')
----------------
#define max(a,b) (a>b)? \
a:b
int main()
{
return 1;
}
----------------
GCC2.95.3 complains:
line.c:4: parse error before `>'
line.c:14: stray '\' in program
line.c:14: parse error before `;'
GCC3.0 give warnings,but still compiles.
line.c:3:14: warning: backslash and newline separated by space
I think followings are possible solutions:
(1) use perl or other method to pre-process the source code before cccp (c
pre-processor) process this source code
This will slow down the compiling speed. So it not recommendated.
(2) tweak the cccp (pre-processor) c-syntax file such as c-parse.y/clex.c to
allow white space at the end of line continuation character.
I think this is a better way. But I can not locate the place to add
this rule in the c syntax file. Generally speaking the Flex program will use
the .l file to define language syntax, but I can not find any file with
extension 'l'. Is the syntax file defined in c-parse.y? Where can I add
this rule to let gcc eat the extra whitespaces ?
Thanks a lot.
-Jack Zhang
More information about the Gcc-help
mailing list