#pragma with SunOS 3 cpp?

Anders Wallgren anders at verity.com
Thu Aug 17 09:29:52 AEST 1989


We are having a problem with the C preprocessor on a Sun 3 running SunOS
3, relating to how it deals with #pragma's.

Since cpp doesn't know about #pragma's, but the other compilers that are
run over the source code do, we tried something along the following line,
the idea being that we define NOT_SUN33 when compiling on other platforms:

int foo(a, b)
int a,b;
{
#ifdef NOT_SUN33
#pragma unused(b)
#endif

return(a)
}

But this confuses cpp: with NOT_SUN33 _undefined_ it complains

Undefined Control in (whatever line contains the #pragma)

Apparently, the #pragma confuses the preprocessor to the point that even
though NOT_SUN33 is undefined, it tries to interpret it while looking for
the #endif.

Our first inclination was to do some kind of macro around it, but you
can't macro around a pre-processor directive, since it doesn't quite
follow up on the recursive nature of that beast.

So, the question is: Has anybody else run into this problem while getting
code to compile under different platforms?  Is there a way to fool the Sun
3 SunOS 3 cpp into ignoring the #pragma while trying to close out the
#ifdef that sits around it?

Anders Wallgren
Software Engineer
Verity, Inc.



More information about the Comp.sys.sun mailing list