Problems with IBM RS6000 C compiler

jsalter at slo.paloalto.ibm.com jsalter at slo.paloalto.ibm.com
Sat Aug 4 11:28:08 AEST 1990


In article <476 at mtndew.UUCP> friedl at mtndew.UUCP (Stephen J. Friedl) writes:
>     I'm not sure where this really belongs so I tried the
>above groups.  There's no RS6000 group, right?

D'is is the place!

>------
>     First, a bug: the following produces a compiler error:
>	1 | #ifdef undef
>	    .......a....
>a - 1506-199: (S) Expecting macro name on #ifdef or #ifndef directive.
>
>I've seen lots of places use this instead of something like
>"#if 0", and my reading of section 3.8 of the standard seems
>to specifically indicate that this should be OK.

I checked my ANSI standard and the only thing I can think of is that
the preprocessor is then available to use #undef as a string literal.

But that's just a guess.  Metaware in ANSI mode complains, while the
standard AIX PS/2 C compiler doesn't think anythings wrong with it.

>------
>Second, I am having problems with prototypes in header files.  It
>seems that this compiler is trying to be compliant with ANSI,
>POSIX, and X/Open (plus maybe the SVID) and I just don't know
>enough about all these standards to know who to blame for this.

If you invoke the compiler as 'xlc', then, as noted in /etc/xlc.cfg,
the preprocessing token _ANSI_C_SOURCE will be defined.  This token
tells the header files that anything outside of the ANSI C (X3.159-1989)
should not be assumed to be available.

>For instance, <sys/stat.h> defines the prototype for stat:
>	extern int stat(char *filename, struct stat *stptr);

<sys/stat.h> is not part of the ANSI C document.  Thus, 'xlc' does not
necessarily have to know about it.

>Shouldn't the "filename" argument be const qualified?  I
>use const all over my code, and the compiler throws up on
>every usage.  The following other functions are mis-prototyped:
>
><fcntl.h>	open()  creat()
><sys/types.h>	stat()  mkdir()  chmod()  mkfifo()
><sys/pwd.h>	getpwnam()
><sys/grp.h>	getgrnam()
>
>plus probably others.  Is this supposed to be like this?  Why?

I believe they are all mentioned in the POSIX 1003.1 document as being
that way.  If you need POSIX stuff, you need to use 'xlc' with the
_POSIX_SOURCE token defined, or use cc.

>Stephen J. Friedl, KA8CMY / Software Consultant / Tustin, CA / 3B2-kind-of-guy
>+1 714 544 6561  / friedl at mtndew.Tustin.CA.US  / {uunet,attmail}!mtndew!friedl


jim/jsalter  IBM AWD, Palo Alto  T465/(415)855-4427   VNET: JSALTER at AUSVMQ
Internet: ibmsupt!jsalter at uunet.uu.net         UUCP: ..!uunet!ibmsupt!jsalter 
	  "I'm going to win.  I always do."
			George Steinbrenner, on ESPN.



More information about the Comp.lang.c mailing list