Operating System - HP-UX
1748181 Members
4157 Online
108759 Solutions
New Discussion юеВ

#define compiler problem still occurring - still an hpux newbie

 
SOLVED
Go to solution
Steve Colbert
Occasional Contributor

#define compiler problem still occurring - still an hpux newbie

I tried using the backslash notation for long #define lines for my code and no luck. Errors from the A.03.27 aCC compiler are still generated. I looked at the 3.27 doc and found the following:

"NOTE: The replacement-list must fit on one line. If the line becomes too long, it can be broken up into several lines provided that all lines but the last are terminated by a "\" character. The following is an example.


#define mac very very long \replacement string

The "\" must be the last character on the line. You cannot add any spaces or comments after it."

Notice that the doc says to use a backslash. Neither convention works for me. If I look at the standard includes, I see backslash continuation characters used throughout.

Is there a compiler switch that I need to implement this behavior? My current settings are

"-c +z +p -AA +DAportable +DD32 -DHPUX -D_REENTRANT -D_THREAD_SAFE -D_POSIX_C_SOURCE=199506L -D_HPUX_SOURCE -D_RWSTD_MULTI_THREAD -D_RWSTD_TEMPLATE"

Thanks in advance for any help...
3 REPLIES 3
Klaus Crusius
Trusted Contributor
Solution

Re: #define compiler problem still occurring - still an hpux newbie

did you verify that there are no whitspace charactes after the backslashes? Use ":set list" in vi to see them. The lines must end with "\$", where "$" represents the NL line terminator.
There is a live before death!
A. Clay Stephenson
Acclaimed Contributor

Re: #define compiler problem still occurring - still an hpux newbie

Hi Steve,
I running Version A.3.30 of aCC and everything worked fine.

I defined a macro like this:
denotes a single backslash character at the end of the line (no trailing spaces)

#define swap(a,b,temp)
{
temp = a;
a = b;
b = temp;
}

Then in the main:
int main()
{
int aa = -1,bb = 1,cc = 0;

printf("Hello world\n");
swap(aa,bb,cc);
return(0);
}

when I did an aCC -P myfile.c I got a myfile.i
which looked like this:

int main()
{
int aa = -1,bb = 1,cc = 0;
printf("Hello world\n");
{ cc = aa; aa = bb; bb = cc};
return(0);
}

Exactly what you would expect; you might try upgrading to the 3.30 version but I would also
create a macro exactly like the one above first as a test. There may be an upper limit to the length of a multi-line macro but I have used some fairly large ones (> 300 chars) without problems.

Regards, Clay
If it ain't broke, I can fix that.
Steve Colbert
Occasional Contributor

Re: #define compiler problem still occurring - still an hpux newbie

Thanks to all.

The problem turned out to be characters after the continuation backslash. Our source is originally written on MS clients and stored to VSS. MS puts CR/LF at end of line. Unix is only LF. I was getting the extra CR character after the continuation character.

Thanks to all for the help!!!