Path: utzoo!attcan!telly!lethe!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!hp-pcd!hpfcso!mev From: mev@hpfcso.HP.COM (Mike Vermeulen) Newsgroups: comp.sys.hp Subject: Re: _HPUX_SOURCE Defintion and ANSI C Message-ID: <7370271@hpfcso.HP.COM> Date: 21 Dec 90 15:25:43 GMT References: <136@bwilab3.UUCP> Organization: Hewlett-Packard, Fort Collins, CO, USA Lines: 33 > 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?) _HPUX_SOURCE tells the compiler to use the same namespace as when compiling in compatability mode (-Ac). It has nothing to do with whether the code is kernel code or not. For background, here is the reason for needing _HPUX_SOURCE: The ANSI C standard specifies exactly which symbols are reserved by the implementation and which ones are available for the user. For example, while the symbol "open" is a UNIX* system call, this name is not reserved by the standard. Thus programs compiling with ANSI C should have the ability to define their own routine named "open" and not have it conflict with the library/system routine. When compiling with -Aa you get a complete ANSI C conformant compile including namespace. There are additional standards that specify additional names. There are predefines that may be used to get these symbols. For example, the POSIX standard specifies that the namespace for the POSIX namespace can be gotten by placing a #define _POSIX_SOURCE prior to including any headers. The names for XOPEN can be gotten with the symbol _XOPEN_SOURCE. Thus _HPUX_SOURCE gets you the complete polluted namespace that is available in compatability mode. --mev disclaimer: not an official response.