Error in compile C by gcc

Hi all,

I compile my c program and get following result

hrnpfc01.c:1387: stray '\' in program
hrnpfc01.c:1387: parse error before `,'
hrnpfc01.c:1388: stray '\' in program
hrnpfc01.c:1388: parse error before `,'
hrnpfc01.c:1396: stray '\' in program
hrnpfc01.c:1396: parse error before `,'

And the code segments are

#define HRNPC_REPORT_REC_FORMAT_1 \
"Transaction Date : %s"

#define HRNPC_ERROR_REPORT_REC_LINE_2 \
"Staff No. Error Message"

I search old post and someone mention that the problme is due to a space after "\"

But I ensure that there is no space after the "\"

Actually, i compile the program on Suse 6.4 by gcc 2.95

Thanks,

Zico

Somehow I think you're looking at the wrong code segments. First you posted two pairs of source code statements and 3 pairs of error messages.

But more to the point, gcc is complaining about an error before a comma. I don't see any commas.

Provided that the blackslash is immediately followed by a newline character, the code you posted is legal.

Sorry for post wrong program segment
The code should be

gogr_write_report_line ( HRNPC_ERROR_REPORT_REC_LINE_2, prep_des );
gogr_write_report_line ( HRNPC_ERROR_REPORT_REC_LINE_3, prep_des );

and the header files contains

#define HRNPC_ERROR_REPORT_REC_LINE_2 \
"Staff No. Error Message"

#define HRNPC_ERROR_REPORT_REC_LINE_3 \
"---------- -----------------------------------------------------------------
-----------------------------------------"

Does the gcc complain about the comma after HRNPC_ERROR_REPORT_REC_LINE_2 and
HRNPC_ERROR_REPORT_REC_LINE_3

thanks

Yesterday you posted different #define's and you stated that you had ensured that the blackslash was immediately follwed by a newline.

What about today's #define's? Are you sure that these backslashes are immediately followed by a newline?

If so, this would look like a gcc bug. But yesterday's post showed that you have at least 4 #define's in total with a blackslash but you have only 3 pairs of error messages. I suspect an error on your part involving those 3 #define's. I would expect a compiler bug to be more consistent.

The "bible" states "each occurrence of a backslash character followed by a newline is deleted, thus splicing lines." I'd be surprised if gcc got this wrong.

If nothing else, join the lines yourself in an editor.

Your right, K&R's bible is not very often ignored. If you are using vi as an editor, try doing a :set list and look for special characters where your defines are. You could also do an od -c <file> and, search for your defines.

Cheers,

Keith