[Top][All Lists]

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

Re: porting to GNUstep from OSX

From: Nicola Pero
Subject: Re: porting to GNUstep from OSX
Date: Thu, 10 Jul 2003 15:41:21 +0100 (BST)

> >> Maybe just some #ifndef's, combined with -D's in the GNUMakefile would
> >> be enough? (I.e., #ifndef GNUSTEP #include <objc/runtime.h> #endif)
> >
> > gnustep-make automatically adds -DGNUSTEP on the command line when
> > compiling for GNUstep.
> >
> > So what I do, and what I guess most people are doing, is
> >
> > #ifndef GNUSTEP
> >  /* Apple specific code */
> > #else
> >  /* GNUstep specific code */
> > #endif
> >
> > You don't need any autoconf or scripting, this should always work: if 
> > you
> > compile GNUstep code using GNUstep, GNUstep is going to be defined; if 
> > you
> > compile for Apple (using GNUstep or PBX), GNUstep is not going to be
> > defined.
> And if you use the GNUstep make package on OS X (and you know, Helge 
> insists on that being ported to OS X every once in a while ;-) you're 
> stuck! :-) Because you also need to identify the runtime, because GNUstep 
> doesn't
> always mean GNU runtime.

Good point.  Which means GNUSTEP might not be enough/the optimal #define
to use if you are interested in runtime details.  Thanks for pointing this

> I always define the following in every GNUmakefile of our packages:
> ifeq "$(OBJC_RUNTIME_LIB)" "gnu"
> endif
> It would be nice and helpful if the GNUstep make package would define 
> this automatically.

Yes - nice and helpful; if you look at core/make/library-combo.make you'll
notice that gnustep-make does *already* define this automatically: it
passes -DGNU_RUNTIME=1 if and only if the gnu runtime is used. :-)

Let me sum up the various options then:

#ifdef GNUSTEP
   /* Code compiled using gnustep-base/gnustep-gui */
#    ifdef GNU_RUNTIME
       /* Code compiled using gnustep-base + GNU runtime */
#    else
       /* Code compiled using gnustep-base + Apple runtime */
#    endif
   /* Code compiled using Apple Cocoa + Apple runtime */

(if you want to support libFoundation too, more #ifdef can be used here to
separate that case too).

If only the runtime is relevant, then

  /* Code compiled using gnustep-base + GNU runtime */
  /* Code compiled using {Apple Cocoa or gnustep-base} + Apple runtime */

is the right way of doing it.

May I also point out that newer GCC compilers automatically predefine
__NEXT_RUNTIME__ if and only if the NeXT ObjC runtime is used.  Because
older compilers don't predefine it, this test is somewhat less useful for
portable code.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]