Error in compile C by gcc | Unix Linux Forums | Programming

  Go Back    


Programming Post questions about C, C++, Java, SQL, and other programming languages here.

Error in compile C by gcc

Programming


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 11-10-2003
zico zico is offline
Registered User
 
Join Date: Jul 2003
Last Activity: 20 October 2009, 10:30 PM EDT
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Network 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
Sponsored Links
    #2  
Old 11-10-2003
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon (Administrator Emeritus)
 
Join Date: Aug 2001
Last Activity: 18 September 2014, 2:40 PM EDT
Location: Ashburn, Virginia
Posts: 9,925
Thanks: 60
Thanked 435 Times in 260 Posts
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.
Sponsored Links
    #3  
Old 11-11-2003
zico zico is offline
Registered User
 
Join Date: Jul 2003
Last Activity: 20 October 2009, 10:30 PM EDT
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
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
    #4  
Old 11-11-2003
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon (Administrator Emeritus)
 
Join Date: Aug 2001
Last Activity: 18 September 2014, 2:40 PM EDT
Location: Ashburn, Virginia
Posts: 9,925
Thanks: 60
Thanked 435 Times in 260 Posts
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.
Sponsored Links
    #5  
Old 11-12-2003
kduffin's Avatar
kduffin kduffin is offline Forum Advisor  
UN1X
 
Join Date: Nov 2003
Last Activity: 21 January 2014, 4:03 PM EST
Location: Belize
Posts: 484
Thanks: 0
Thanked 3 Times in 2 Posts
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

Last edited by kduffin; 11-17-2003 at 09:53 PM..
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Kernel compile error mdop Ubuntu 2 08-24-2011 06:32 AM
Compile PHP on AIX 5.2 Error dtiger AIX 2 03-18-2011 01:24 AM
aCC Compile error message alert0919 Programming 1 05-06-2009 08:32 AM
C compile error kuampang Programming 3 11-29-2006 11:30 PM
Compile error coulio Programming 9 06-30-2006 05:43 AM



All times are GMT -4. The time now is 03:45 PM.