delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/07/24/12:36:53

From: Christopher Croughton <crough45 AT amc DOT de>
Message-Id: <97Jul24.183010gmt+0100.17030@internet01.amc.de>
Subject: Re: sizeof() in #if
To: eldredge AT ap DOT net (Nate Eldredge)
Date: Thu, 24 Jul 1997 17:34:41 +0100
Cc: crough45 AT amc DOT de, chirayu AT radiolink DOT net, djgpp AT delorie DOT com
In-Reply-To: <199707241623.JAA27109@adit.ap.net> from "Nate Eldredge" at Jul 24, 97 05:23:59 pm
Mime-Version: 1.0

Nate Eldredge wrote:

> I have seen programs which attempt to be ultraportable work by creating
> their own definitions before compiling. Example:
[snip]
> - And have everything that needs the sizes #include sizes.h, and put the
> appropriate dependencies in the makefile.
> You can take care of many machine dependencies this way. I've seen it done
> for endian-ness as well.

Well, yes, that's the principle behind the GNU/Unix 'configure' script.
You can also test a lot of other things, for instance using the preprocessor
to include all the standard headers and then grep for library functions
(one missing from rigidly conforming ANSI libraries is the very useful
stricmp to do case-insensitive compares, for instance).

It's probably the best way to do it for endian-ness, and that can be put
into the header file as well.  Probably as macros (like the network
macros in BSD for network address conversions).

Although it's portable and makes things more general, it's not exactly
elegant (actually the Unix configure isn't portable either; it works
on most Unices but not on DOS for instance).

Now, how do I in a portable way test for which C compiler might be available?
I can do it easily in 4DOS, but COMMAND.COM compatibility is a lot harder...

Chris

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019