www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/11/20/14:31:35

From: Hans-Bernhard Broeker <broeker AT physik DOT rwth-aachen DOT de>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: HELP: S_ISDIR() ?????
Date: 20 Nov 2001 19:18:07 GMT
Organization: Aachen University of Technology (RWTH)
Lines: 40
Message-ID: <9tea9f$hee$1@nets3.rz.RWTH-Aachen.DE>
References: <0rqivtk7vhhprds46r1a48o07rvp82isuc AT 4ax DOT com> <nh9lvt0l86tc16qlcrthud9a2gf5jiaje6 AT 4ax DOT com>
NNTP-Posting-Host: acp3bf.physik.rwth-aachen.de
X-Trace: nets3.rz.RWTH-Aachen.DE 1006283887 17870 137.226.32.75 (20 Nov 2001 19:18:07 GMT)
X-Complaints-To: abuse AT rwth-aachen DOT de
NNTP-Posting-Date: 20 Nov 2001 19:18:07 GMT
Originator: broeker@
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019