home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / std_unix / volume.16 / text0017.txt < prev    next >
Encoding:
Internet Message Format  |  1989-08-11  |  2.9 KB

  1. From: Ray Butterworth <uunet!watmath.waterloo.edu!rbutterworth>
  2.  
  3.  
  4. In article <1957@unisoft.UUCP>, john@unisoft.UUCP (John Sovereign) writes:
  5. > The IEEE 1003.1 POSIX standard defines the feature test macro
  6. > _POSIX_SOURCE to control the scope of POSIX defined-symbols.
  7. > While POSIX does not specify any other macros, the Rationale
  8. > does suggest some macros to represent several common "unix"
  9. > environments, e.g., _V7, _BSD4_3, and _SYSV3.
  10.  
  11. > "Unix" is too
  12. > broad of definition to be of much use to application programs.
  13.  
  14. Definitely not true.
  15.  
  16. Consider an applicaton that needs to see if a file is readable:
  17.     #if defined(unix)
  18.         unreadable = access(file, R_OK);
  19.     #else
  20.         {
  21.             register FILE *stream = fopen(file, "r");
  22.             unreadable = (stream == 0);
  23.             if (!unreadable)
  24.                 fclose(stream);
  25.         }
  26.     #endif
  27.  
  28. Now, are you suggesting that I have to change "defined(unix)"
  29. to "defined(V7) || defined(BSD4_2) || defined(BSD4_3) || ..." ?
  30. And do you expect me to change this every time there might be
  31. a new release of some version of unix somewhere?
  32.  
  33. As for all these _NAME defintions, I definitely think they are
  34. going about this the wrong way.  For instance, if I'm implementing
  35. the pANS time functions, I am allowed to define symbols in the
  36. header file such as _jan, _feb, ... or _mon, _tue, ... that I
  37. might need internally.  But that is going to include the symbols
  38. _dec and _sun, which might screw up other people's applications
  39. programs if they use "#if defined(_sun)" thinking that would
  40. be true only if they are running on a Sun.
  41.  
  42. I can probably avoid that, since I know about it, but what if I
  43. have _tangent in my math library, and several years from now
  44. "Tangent Software" decides to use _tangent to indicate that you
  45. are using their compiler.  If you use "if defined(_tangent)",
  46. your software will probably be buggy when compiled on my system,
  47. and it won't be your fault and it won't be my fault.
  48.  
  49. For the applications I am writing now, which must compile and
  50. run on several different systems (both unix and non-unix), I
  51. don't rely on these "standard" names.  Instead I have a header
  52. file on each system and in it are definitions for the environment
  53. on that machine.  For example I have OS_UNIX, OS_BSD, OS_BSD_4_3,
  54. HW_VAX, and HW_VAX_780 on this machine, OS_SUN, ... on another,
  55. OS_GCOS8 ... on another, ....
  56.  
  57. At the time I set this up I was only concerned with the Operating
  58. System and the HardWare, so I didn't use the TargetSystem and
  59. similar prefixes suggested in an earlier posting, but they are
  60. a better idea if you want to be able to have cross-compilers.
  61.  
  62. I don't understand why X3J11 didn't try to standardize these
  63. names in some way, even if only as a note in the appendix
  64. suggesting that this is the way to do it.  As long as they
  65. are forcing everyone to change sun to _sun or some other
  66. unspecified name, they might as well have suggested TS_SUN
  67. (and thereby not require the leading underscore).
  68.  
  69. Volume-Number: Volume 16, Number 15
  70.  
  71.