Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!wuarchive!emory!att!pacbell.com!ucsd!mvb.saic.com!ncr-sd!sdd.hp.com!hplabs!hpl-opus!hpcc05!hpcuhb!hpcllla!hpclisp!hpclscu!shankar From: shankar@hpclscu.HP.COM (Shankar Unni) Newsgroups: comp.sys.hp Subject: Re: _HPUX_SOURCE Defintion and ANSI C Message-ID: <1340157@hpclscu.HP.COM> Date: 21 Dec 90 20:43:33 GMT References: <136@bwilab3.UUCP> Organization: Hewlett-Packard Calif. Language Lab Lines: 44 > I am trying to write ANSI C programs that use calls to UN*X specific > functions. When compiling in ANSI mode i.e. -Aa the compiler cannot find > function prototypes and definitions in some header files. In non ANSI mode > the definitions are found. > > I was told to resolve this problem by #defining _HPUX_SOURCE. This solves > the problem of the compiler not finding the prototypes but raises some > questions about what it does. I was also told, by someone else, that the > _HPUX_SOURCE tells the compiler that I am compiling kernel code. Is this > true? Is there a better way to get access to the routines than _HPUX_SOURCE? > What problems am I opening up by using this? (i.e. am I allowing access to > kernel routines that I am not supposed to?) The ANSI C standard mandates the contents of certain header files (the "magnificent 15", including , , , etc). These files can, in a *strictly conforming* ANSI C implementation, only contain those identifiers that the ANSI C standard says that it can. The -Aa flag on HP-UX is supposed to make the C compiler present a fully conformant ANSI C implementation, which is why it suddenly hides all the non-ANSI symbols under _HPUX_SOURCE. The convention adopted by the Unix-ish standards (which *also* have name-space pollution constraints) is to specify that an ANSI C compiler which defines a certain magic define (-D...) will get a name space that conforms to that standard: -D_POSIX_SOURCE: Posix 1003.2 -D_XOPEN_SOURCE: X/Open In the same vein: -D_HPUX_SOURCE: everything on HP-UX. _HPUX_SOURCE is a superset of _POSIX_SOURCE, which is a superset of the ANSI C name space. (By the way, in "compatibility mode", the -D_HPUX_SOURCE is defined automatically for you, something we cannot do in -Aa mode, because it will break ANSI C conformance). ----- Shankar Unni E-Mail: Hewlett-Packard California Language Lab. Internet: shankar@hpda.hp.com Phone : (408) 447-5797 UUCP: ...!hplabs!hpda!shankar