home *** CD-ROM | disk | FTP | other *** search
- From: Ray Butterworth <uunet!watmath.waterloo.edu!rbutterworth>
-
-
- In article <1957@unisoft.UUCP>, john@unisoft.UUCP (John Sovereign) writes:
- > The IEEE 1003.1 POSIX standard defines the feature test macro
- > _POSIX_SOURCE to control the scope of POSIX defined-symbols.
- > While POSIX does not specify any other macros, the Rationale
- > does suggest some macros to represent several common "unix"
- > environments, e.g., _V7, _BSD4_3, and _SYSV3.
-
- > "Unix" is too
- > broad of definition to be of much use to application programs.
-
- Definitely not true.
-
- Consider an applicaton that needs to see if a file is readable:
- #if defined(unix)
- unreadable = access(file, R_OK);
- #else
- {
- register FILE *stream = fopen(file, "r");
- unreadable = (stream == 0);
- if (!unreadable)
- fclose(stream);
- }
- #endif
-
- Now, are you suggesting that I have to change "defined(unix)"
- to "defined(V7) || defined(BSD4_2) || defined(BSD4_3) || ..." ?
- And do you expect me to change this every time there might be
- a new release of some version of unix somewhere?
-
- As for all these _NAME defintions, I definitely think they are
- going about this the wrong way. For instance, if I'm implementing
- the pANS time functions, I am allowed to define symbols in the
- header file such as _jan, _feb, ... or _mon, _tue, ... that I
- might need internally. But that is going to include the symbols
- _dec and _sun, which might screw up other people's applications
- programs if they use "#if defined(_sun)" thinking that would
- be true only if they are running on a Sun.
-
- I can probably avoid that, since I know about it, but what if I
- have _tangent in my math library, and several years from now
- "Tangent Software" decides to use _tangent to indicate that you
- are using their compiler. If you use "if defined(_tangent)",
- your software will probably be buggy when compiled on my system,
- and it won't be your fault and it won't be my fault.
-
- For the applications I am writing now, which must compile and
- run on several different systems (both unix and non-unix), I
- don't rely on these "standard" names. Instead I have a header
- file on each system and in it are definitions for the environment
- on that machine. For example I have OS_UNIX, OS_BSD, OS_BSD_4_3,
- HW_VAX, and HW_VAX_780 on this machine, OS_SUN, ... on another,
- OS_GCOS8 ... on another, ....
-
- At the time I set this up I was only concerned with the Operating
- System and the HardWare, so I didn't use the TargetSystem and
- similar prefixes suggested in an earlier posting, but they are
- a better idea if you want to be able to have cross-compilers.
-
- I don't understand why X3J11 didn't try to standardize these
- names in some way, even if only as a note in the appendix
- suggesting that this is the way to do it. As long as they
- are forcing everyone to change sun to _sun or some other
- unspecified name, they might as well have suggested TS_SUN
- (and thereby not require the leading underscore).
-
- Volume-Number: Volume 16, Number 15
-
-