Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!mips!carbon!stanford.edu!morrow.stanford.edu!pangea.Stanford.EDU!karish From: karish@pangea.Stanford.EDU (Chuck Karish) Newsgroups: comp.unix.aix Subject: Re: xlc and brain damage Summary: Standards Message-ID: <1991May16.003051.10069@morrow.stanford.edu> Date: 16 May 91 00:30:51 GMT References: <2811@sapwdf.UUCP> Sender: news@morrow.stanford.edu (News Service) Organization: Mindcraft, Inc. Lines: 46 In article <2811@sapwdf.UUCP> Bill Wohler writes: > the following example compiles under cc, but not under xlc. why not? When the C compiler is invoked as 'xlc', it enforces the namespace limitations specified by POSIX.1. No symbols other than those defined by Standard C are visible in the headers unless a feature test macro is #defined or the symbol is in the namespace reserved for the implementation. 'cc' defines '_AIX', which causes '_POSIX_SOURCE' and '_XOPEN_SOURCE' to be set as well. > is this brain damage in the way dir.h or standards.h is set up? > the meat of dir.h is only included if _POSIX_SOURCE is defined, > which isn't defined when _ANSI_C_SOURCE is as in the case with > xlc. That's what the standards require. Declarations of 'DIR' and 'opendir()' would infringe on the namespace that's reserved for the programmer. > does anyone really use xlc? Yes. You do, too; 'cc' actually is an alias for 'xlc'. Calling the compiler as 'xlc' doesn't just change the feature test macros. It changes the semantics of the compiler in many subtle ways to match the C Standard. >[wohler@is0002:507]% cat foo.c >#include >foo() >{ > DIR *dirname = opendir("/tmp"); >} >[wohler@is0002:508]% cc -c foo.c >[wohler@is0002:509]% xlc -c foo.c > 5 | DIR *dirname = opendir("/tmp"); > ........a....b......................... >a - 1506-045: (S) Undeclared variable. >b - 1506-045: (S) Undeclared variable. >Bill Wohler -- Chuck Karish karish@mindcraft.com (415) 323-9000 karish@forel.stanford.edu