delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/03/04/18:14:42

From: "Jon A. Cruz" <jonc AT twinsun DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: [Q] What #defines for cross-platform
Date: Tue, 04 Mar 1997 12:59:02 -0800
Organization: Twin Sun Inc, El Segundo, CA, USA
Lines: 79
Message-ID: <331C8D16.2FD2@twinsun.com>
References: <331B3412 DOT FF4 AT twinsun DOT com> <331BB1F6 DOT 16ABE34B AT alcyone DOT com>
Reply-To: jonc AT twinsun DOT com
NNTP-Posting-Host: 192.207.224.4
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Erik Max Francis wrote:
> 
> Jon A. Cruz wrote:
> 
> > I have a quick question. I'm working on some code for true
> > cross-platform compiling (i.e. DOS, MS Windows, Windows CE, Unix, Mac,
> > Newton, etc., not just Win95 and WinNT) and was looking for suggestions
> > on what #defines I should use?
> >
> > What are you using, and why?
> 
> Uh, that's a huge, massive question.
> 

Yes, I know. That's why I asked it here.

> First, Newton?  Newton programming, as far as I know, is done with
> NewtonScript, which is not C/C++, and so cross-platform compiling between
> other platforms is impossible, since NewtonScript does not exist on other
> platforms.  Others are welcome to correct me if there's some new
> development in Newton programming.

Well, I mainly mentioned the Newton to be a bit light-hearted, and to
knock out those (IMHO) annoying people who call compiling only for
Windows NT and Windows 95 "cross-platform". There are, however, c or c++
tools for Newton. (I think they are used mainly for small routines, and
may not be publically released yet, but don't quote me on that.)


> 
> Second, it depends on what kind of cross-platform development you're trying
> to do.  Most of my recreational work is (ANSI C) cross-platform stuff, so I
> might be able to help.  If you're interested in graphics, sound, or other
> things, then there are no "#defines" you can make to make things
> cross-platform; you have to write a layer that interfaces between your code
> and the platform-specific code to do the job.  This is often not easy,
> since different systems have different advantages and paradigms, and so
> making them all mesh nicely is not easy (but possible).
> 
> First off is probably creating some typedefs for integral datatypes, since
> ANSI C/draft standard C++ does not strictly specify the sizes of the
> datatypes.  Having types like signed16, unsigned32, etc., can help when the
> sizes of the types matter.

Yup. One of the first things I did.

> 
> You'll also tend to have defines and typedefs for things which _are_
> standard but aren't yet supported on a particular compiler; for instance, I
> use the new C++ standard bool datatype even though it's not universally
> supported.  On MetroWerks CodeWarrior 9 (I haven't bothered to check 10 or
> 11), it isn't supported yet, so typedefs and defines are required to make
> an object which _looks_ like a bool (although one generally has to be
> careful because simple defines don't get all the features of the C++ bool).
> 
> You'd probably have to go into more detail about exactly what it is you're
> looking for.  Cross-platform programming is a huge, wide-open subject.
> 

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

Currently I'm looking at little command-line utilities, common utility
source modules for different programs, etc.

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?

I have been looking at these items:

* OS
* compiler bugs (Hey, I'm using MS compilers, 'nuff said)
* byte order
* size of types
* 64k pointer limit
* text/binary mode for files

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"

- Raw text -


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