Mail Archives: djgpp/1998/08/20/13:15:58
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
- Raw text -