delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/03/13/13:34:20

From: Erik Max Francis <max AT alcyone DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: [Q] What #defines for cross-platform
Date: Wed, 12 Mar 1997 08:46:54 -0800
Organization: Alcyone Systems
Lines: 56
Message-ID: <3326DDFE.66E58C99@alcyone.com>
References: <331B3412 DOT FF4 AT twinsun DOT com> <331BB1F6 DOT 16ABE34B AT alcyone DOT com> <331C8D16 DOT 2FD2 AT twinsun DOT com>
NNTP-Posting-Host: newton.alcyone.com
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Jon A. Cruz wrote:

> I was intentionally vauge to begin with. I wanted to get good answers to
> what I need, not what I ask.

If you don't ask for what you need, you're likely not going to get it.

> I have two main questions in my head 1) what are commonly used defines
> (spelling), and 2) what are things that need to be watched for?

You can use whatever defines you like, and there isn't any universally or
even commonly used agreement.

> I have been looking at these items:
> 
> * OS
> * compiler bugs (Hey, I'm using MS compilers, 'nuff said)

Just have macros specifying which OS and compiler you're using.

> * byte order

Have LITTLE_ENDIAN and BIG_ENDIAN, and have them do the appropriate thing
in your high-level I/O routines.

> * size of types

As I said earlier, just make OS/compiler-dependent macros that specify
16-bit signed types, 16-bit unsigned types, etc.

> * 64k pointer limit

Don't know what you think you could do about this.  Are you talking about
near pointers in MSDOS?

> * text/binary mode for files

This is already handled for you by stdio; just open it as text or binary,
appropriately, when calling fopen.

> I don't want to say things like "#ifdef __INTEL__" all down in my code,
> but more like "#ifdef __BIG_ENDIAN__" or "#if _BYTE_ORDER = _BIG_ENDIAN"

You can either do all the preprocessing in one header file where it makes
macros that do the appropriate thing on your platform, or you can have the
condition compilation occur in the code.  Either way it's the same thing.

-- 
       Erik Max Francis, &tSftDotIotE / email:  max AT alcyone DOT com
                     Alcyone Systems /    web:  http://www.alcyone.com/max/
San Jose, California, United States /    icbm:  37 20 07 N  121 53 38 W
                                   \
              "I am become death, / destroyer of worlds."
                                 / J. Robert Oppenheimer (quoting legend)


- Raw text -


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