Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!elroy.jpl.nasa.gov!decwrl!infopiz!lupine!rfg From: rfg@NCD.COM (Ron Guilmette) Newsgroups: comp.std.c Subject: Re: Frustrated trying to be portable Message-ID: <4341@lupine.NCD.COM> Date: 10 Mar 91 08:43:56 GMT References: <4204@lupine.NCD.COM> <19085@rpp386.cactus.org> <15382@smoke.brl.mil> Organization: Network Computing Devices, Inc., Mt. View, CA Lines: 48 In article <15382@smoke.brl.mil> gwyn@smoke.brl.mil (Doug Gwyn) writes: > >In fact I am well aware of AT&T's "standalone" mode for a few commands >such as "ls", and how they are used. On the other hand, I don't think >you have thought this matter through very well. If you have an >application that performs useful work in a "freestanding" C environment, >it must directly access hardware registers or be linked with some... The case that I was most concerned about (and the reason I raised the issue of __HOSTED_STDC__) had nothing to do with embedded systems or device registers or any low-level stuff like that. No. The case that I was worried about was GCC on a Sun4 under SunOS 4.0. In *that* (perhaps rather common) case the compiler correctly defines __STDC__ to 1 because the implementation meets the minimal criteria for a standalone implementation. Now, if you are using this compiler in this environment, and you do: #ifdef __STDC__ #include #endif #ifdef __STDC__ /* some use of `size_t' */ #endif you are going to get errors because although GCC is a minimally compliant implementation of ANSI C, the environment it sits in rarely includes a set of maximally compliant header files and libraries. That's where having __HOSTED_STDC__ would come in handy. If it were defined, I could be assured that after was included, I could use the type size_t, whereas if __HOSTED_STDC__ were not defined, I might write the code to play it safe and use something bland like `int' instead of size_t. I could name a few dozen more examples of places where Sun or DEC or HP, or Motorola or Intel "system" header files (for various releases of UNIX which these companies have made) are not quite right (or not quite enough) to really get you up to a "complete" and "conformant" hosted implementation of ANSI C. So if you want more examples, just let me know. -- // Ron Guilmette - C++ Entomologist // Internet: rfg@ncd.com uucp: ...uunet!lupine!rfg // New motto: If it ain't broke, try using a bigger hammer.