Mail Archives: djgpp/2001/11/20/14:31:35
Radical wrote:
> which is better to use:
> #ifdef __DJGPP__
> ...or...
> #ifdef __GNUC__
Neither. It's like asking: which is better: an apple or a nails?
Depends on what you need it for.
__DJGPP__ is defined *only* on DJGPP, __GNUC__ is defined on lots of
other platforms. If and only if you know that a particular feature is
common to all versions of GNU CC, you should use __GNUC__.
Best practice usually is to use neither of the two, but rather use
GNU's "autoconf" to test for the exact features themselves, not the
platform they run on. Then you can write things like #if
HAVE_SYS_STAT_H or #if HAVE_SNPRINTF and so on.
In the original case at hand, you'ld write
#ifndef S_ISDIR
# if defined(S_IFDIR) && defined(S_IFMT)
# define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR)
# else
# error "no definition of S_ISDIR!"
#endif
and be done with it.
> in that someone who wants to compile for Linux GCC and not just
> MSDOS/DJGPP, is GNUC acceptable?
Probably no. You don't know where else GNU CC is used.
--
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.
- Raw text -