Article View: comp.std.unix
Article #290Re: ANSI vs POSIX on <sys/types.h>
From: Doug Gwyn
Date: Mon, 04 Jun 1990 17:04
Date: Mon, 04 Jun 1990 17:04
44 lines
2535 bytes
2535 bytes
From: Doug Gwyn <gwyn@smoke.brl.mil> In article <714@longway.TIC.COM> From: Andy Tanenbaum <ast@cs.vu.nl> >If one replaced the *_t types by their definitions everywhere, then a >decision to change pid_t from, say, int, to, say, long, would require >a real expert to dig through all the code to find those int's that really >are pid_t's. You miss an important point -- we're talking about system code provided by the IMPLEMENTOR, not application code. Presumably the implementor IS a real expert, and furthermore is in charge of the decision about what specific typedefs will be used. I suspect that many implementors will provide (for implementation use only) additional headers, say <sys/_types.h>, that define identifiers such as __pid_t that are just like the POSIX ones but taken from the name space reserved for use by implementations. Then, for example, <sys/types.h> could contain: /* <sys/types.h>: */ #include <sys/_types.h> #define pid_t __pid_t and <signal.h> could contain: /* <signal.h>: */ #include <sys/_types.h> #ifdef _POSIX_SOURCE extern int kill(__pid_t, int); #endif which addresses the maintenance issue that the implementor might be faced with. (Applications are oblivious to all this substructure, which is the way things SHOULD be.) >This then raises the question of how to make pid_t known. In the example >implementation given, <sys/types.h> is included in raise.c. If this is >indeed legal, then that is clearly one way to do it, as presumably all the >names introduced by <sys/types.h> are not present in the object file, >raise.o, and thus do not pollute the name space. Yes, that was one of the points of the example. >However, why do you urge not to put #include <sys/types.h> into <signal.h> >under protection of #ifdef _POSIX_SOURCE? Because I don't think that use of _POSIX_SOURCE should pollute the name space beyond the minimum required for POSIX. Volume-Number: Volume 20, Number 26
Technical Details
Message-ID:
<717@longway.TIC.COM>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!longway!std-unixReferences:
<711@longway.TIC.COM> <712@longway.TIC.COM> <714@longway.TIC.COM>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!longway!std-unix From: gwyn@smoke.brl.mil (Doug Gwyn) Newsgroups: comp.std.unix Subject: Re: ANSI vs POSIX on <sys/types.h> Message-ID: <717@longway.TIC.COM> Date: 4 Jun 90 17:04:29 GMT References: <711@longway.TIC.COM> <712@longway.TIC.COM> <714@longway.TIC.COM> Sender: std-unix@longway.TIC.COM Reply-To: std-unix@uunet.uu.net Organization: U.S. Army Ballistic Research Laboratory, APG, MD. Lines: 44 Approved: jsq@longway.tic.com (Moderator, John S. Quarterman)