From: ams AT ludd DOT luth DOT se (Martin Str|mberg) Newsgroups: comp.os.msdos.djgpp Subject: Re: Porting from Linux Date: 20 Aug 1998 17:02:32 GMT Organization: University of Lulea, Sweden Lines: 30 Message-ID: <6rhkr8$l8e$3@news.luth.se> References: NNTP-Posting-Host: queeg.ludd.luth.se To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Andrew N. Bainbridge (anb AT dcs DOT st-and DOT ac DOT uk) wrote: : What is the standard way to allow one set of source code to compile under : Linux GCC and DJGPP? Because my program uses the comms port, the joystick : and some VGA graphics the code under Linux is quite different to that : under DJGPP. I want to put both sets of code into each source file and : use something like #ifdef to allow the compiler to choose which sections : to compile. : : This must be done regularly, so I expect there is a more elegant way than : what I would come up with myself. One way is to select constants that is defined only on one of the platforms. To get a list of potential candidates run "gcc -v some_c_file_which_contents_do_not_matter.c" and select one of the things preceded by "-D". I would think __linux__ is a good one for linux, while __unix__ is not because I think DJGPP defines that too. Then your code becomes: #ifdef __linux__ /* Some linux specific things. */ #endif #ifdef some_nice_DJGPP_define(__DJGPP__?) /* The DJGPP specific things that does the same as the linux specific things. */ #endif Silence, MartinS