In article <40**********************@freenews.iinet.net.au> ,
Sisyphus <ka**********@iinet.net.au> wrote:
Hi,
Is there anything in the ANSI C standard covering the means by which I
can determine the operating system and compiler being used (at the
preprocess stage) ?
Not specified in the standard, but there is a mechanism that the standard
allows and that most compilers use:
If so, then how might I determine (at the preprocess stage) whether the
operating system upon which the app is being built is Win32 or not, and
whether the compiler being used is gcc or not ?
Most compilers will define a preprocessor macro that identifies
the compiler and operating system. (There's nothing preventing an
implementation for the DeathStation from defining all such macros and
then blowing up your terminal when it sees code that uses extensions
specific to some other compiler, but with implementations that attempt
to provide a nonnegative QoI this is usually not a problem.)
The standard allows implementations to use most symbols beginning with "_"
(and all symbols beginning with "__") for any use the implementors can
come up with, so these macros typically look something like "__unix__"
or "_WIN32".
If, on the other hand, this question is OT here, can someone provide me
with the name of a newsgroup where I could (legitimately) ask about
achieving such a determination.
Given the information above, you'd be better off checking your compiler's
documentation to find what macro(s) it defines. If you can't find it
there, a newsgroup for your OS or compiler should be able to tell you.
Potentially helpful newsgroups, from the CLC welcome message:
--------
Languages and Programming
news:comp.lang.c++ The C++ Programming Language
news:comp.lang.asm.x86 x86 assembly language programming
news:comp.programming Non-language specific programming
news:comp.graphics.algorithms Issues of computer graphics
Compilers
news:gnu.gcc The gcc free C compiler
news:comp.os.msdos.djgpp x86 version of the free gcc C
compiler
Operating Systems
news:comp.os.msdos.programmer DOS, BIOS, Memory Models,
interrupts, screen handling,
hardware
news:comp.os.ms-windows.programmer.misc MS/Windows: Mice, DLLs, hardware
news:comp.os.ms-windows.programmer.win32 MS 32-bit API
news:comp.os.os2.programmer.misc OS/2 Programming
news:comp.sys.mac.programmer.misc Macintosh Programming
news:comp.unix.programmer General Unix: processes, pipes,
POSIX, curses, sockets
news:comp.unix.[vendor] Various Unix vendors
news:comp.os.linux.development.apps Linux application programming
--------
dave
--
Dave Vandervies
dj******@csclub.uwaterloo.ca
Start with your English classes; only when you've got the point that spelling
is not completely optional are you ready to proceed to the rather more exacting
discipline of programming. --Richard Bos in comp.lang.c