[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Daniel K. Spicer wrote: > I'm doing a code port from Solaris to Suse Linux. The ported code will need to run on both so I need a preproccessor directive in the .c files like: > > #ifdef SUSE > ...Linux code > #else > ...Solaris code > #endif > > I'm using gcc. Does anyone know of an existing macro for Suse or Solaris to do this with? > Or another good way of doing it? > > Thanks, > -Dan
You can work some magic in your makefile with `uname`... that'll at least get you a kernel name (ie 'Linux' or 'Solaris'), not sure about SUSE specifically.
- d
Dan, Just to make sure you don't go overboard with ifdefs, you don't need too many. I've written code that compiled for Mac OS X, Solaris and Linux. I'll let you know what I used to separate them. I have a strong feeling that I was lazy and used compiler flags like "-DLINUX" in my makefile to define which OS I was on. You're better of using LINUX as your #define than SUSE. (try looking at a configure script from a project on on sourceforge, like snort).
As long as you're not doing anything funny at the bit level (where ordering matters) your code will cross compile simply. Shared memory is done differently on all platforms (at least I don't remember using the same code on each). For your network stuff, make sure to use ntohl and htonl (and shorts).
HTH Amul ___________________________________________________________________________ Philadelphia Linux Users Group -- http://www.phillylinux.org Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce General Discussion -- http://lists.phillylinux.org/mailman/listinfo/plug