[Prev][Next][Index][Thread]

Re: use of #ifdefs



On Fri, 15 Sep 1995, jon seymour wrote:

> I have a suggestion about the use of #ifdefs if they
> are needed - try to put all the operating system specific switches in a
> single config header file. 

[example excised]

I agree in principle, but what you'd wind-up with is hundreds of different
#ifdef types ... some for processes, some for threads, some for graphics,
some for file handling.  I'd prefer to be able to read the source and
tell which changes apply to the platform I'm working on.  I think #ifdef OS2
gives us that.

I can tell you this is the way we are handling the IBM Taligent port. 
It's going to be exactly the same situation with Java.  As an "investor"
IBM gets periodic "code drops" from Taligent ... about every three months,
during which time we port and tweak to get it running under OS/2.  Then
a *new* code drop arrives involving changes to most of the files we have
touched, meaning we have to go through a "merge" to roll our changes into
the new code.  Having the changes clearly delineated helps immensely. 
Additionally, we give our code back to Taligent where most of it can sit
in the common tree due to our #ifdefs. 

Now, I don't know about Sun's future plans for a common source base, but
seems to me that we shouldn't do anything to preclude it.  I *do* know
that Sun has said there would be some fairly significant changes between
Alpha and ship, so whatever we can do to clearly indicate our changes
will help us "merge" with the new code.  Something interesting of note is
that in *one* of the awt* header files there is an #ifdef WIN32 ... I
don't know how or why that crept in there, but it may be a prelude of
things to come.

My general point was that it really doesn't take *that* much additional
effort to bracket changes with #ifdefs ... much of the code is portable
anyway.  The one big exception being the window management stuff ... which
we can dup the source for and modify as needed.  But at least we can keep
the source base largely common that way.  I think it's worth trying ...
I've seen it work here (at IBM).  Taligent is written natively on AIX, we
port to OS/2, and there is a NT/95 port going on ... yet we manage to get
probably 75-80% of the code common (more in some areas, less in others). 

Granted, using #ifdef OS2 throughout may not be the best way either ... we
should be open to other ideas for maintaing a common base with the least
inconvenience to ourselves.  For example, writing wrappers around some
OS/2 functions to create Solaris look-alike functions -- like in the area
of process management or interprocess communications.  These could be
placed in a common library that we link with.  Neither me nor Jon has the
final solution ... it maybe a conglomeration of the two, or it may be
completely different.  Anyone else have ideas in this area? 

P.S. sorry for the long-winded post, the port has my wheels turning. :)

=========================================================================
Brett Wooldridge | "I believe OS/2 is destined to be the most important
brettw@io.com    |  operating system, and possibly program, of all time."
                 \____                                  -- Bill Gates
IBM Taligent Team     \
brettw@austin.ibm.com | Amiga3K-NetBSD <=== ethernet ===> 486/100Mhz-Warp
=========================================================================



References: