Path: utzoo!attcan!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!ibmsupt.uucp!!jsalter From: jsalter@slo.paloalto.ibm.com Newsgroups: comp.lang.c Subject: Re: Problems with IBM RS6000 C compiler Message-ID: <1990Aug4.012808.10041@ibmpa> Date: 4 Aug 90 01:28:08 GMT References: <476@mtndew.UUCP> Sender: news@ibmpa (news id) Reply-To: jsalter@slo.UUCP (James Salter) Organization: IBM AWD Development, Palo Alto Lines: 62 In article <476@mtndew.UUCP> friedl@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, defines the prototype for stat: > extern int stat(char *filename, struct stat *stptr); 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: > > open() creat() > stat() mkdir() chmod() mkfifo() > getpwnam() > 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@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@uunet.uu.net UUCP: ..!uunet!ibmsupt!jsalter "I'm going to win. I always do." George Steinbrenner, on ESPN.