X-Authentication-Warning: kendall.sfbr.org: jeffw set sender to jeffw AT darwin DOT sfbr DOT org using -f Date: Fri, 4 May 2001 16:08:23 -0500 From: JT Williams To: Eli Zaretskii Cc: djgpp AT delorie DOT com Subject: Re: __DJGPP__ and MSDOS Message-ID: <20010504160823.A19921@kendall.sfbr.org> Mail-Followup-To: Eli Zaretskii , djgpp AT delorie DOT com References: <20010430093758 DOT A5379 AT kendall DOT sfbr DOT org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: ; from eliz@is.elta.co.il on Mon, Apr 30, 2001 at 07:23:20PM +0300 Reply-To: djgpp AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk -: > My experiments lead me to believe that __MSDOS__ is defined `immediately' -: > by the preprocessor (by virtue of using a gcc that was built for DOS), -: > but that __DJGPP__ is not defined until I #include a *system* header. -: -: That might be true (depending on what version of GCC do you use), but -: even if it is so, the necessary header is included by the preprocessor -: before anything else, because the specs file tells it to do so with the -: -isystem switch. -: -: > I can validly #ifdef __MSDOS__ inside "foo.h", but I have to wait until -: > _after_ to validly #ifdef __DJGPP__? -: -: No. __DJGPP__ should work exactly like __MSDOS__. If you see something -: else, please post a short test program. Ok, there are two files `hello.[ch]' at the end of this note that I've been using to reproduce the behavior described above. I'm using stock djdev2.03 with DOS 5.0. % gcc --version 2.7.2.1 % bash --version GNU bash, version 2.04.7(1)-release (i386-pc-msdosdjgpp) Copyright 1999 Free Software Foundation, Inc. 1. Compile `hello.c' with headers #included in this order: #include "hello.h" #include % gcc -c hello.c In file included from hello.c:1: hello.h:6: warning: #warning Found msdos. <-- does *not* see __DJGPP__ % gcc -o hello.exe hello.o % ./hello.exe hello, world hello, djgpp <-- but hello.c *does* see __DJGPP__ hello, dos 2. Compile `hello.c' with headers in this order: #include #include "hello.h" % gcc -c hello.c In file included from hello.c:2: hello.h:2: warning: #warning Found djgpp. <-- hello.h:6: warning: #warning Found msdos. % gcc -o hello.exe hello.o % ./hello.exe hello, world hello, djgpp <-- hello, dos So, depending on header #include order, __DJGPP__ may not be defined and available for #ifdef testing inside `hello.h'. TIA jeff williams Files hello.h, hello.c: % cat hello.h #ifdef __DJGPP__ #warning Found djgpp. #endif #ifdef __MSDOS__ #warning Found msdos. #endif % cat hello.c #include "hello.h" #include int main(void) { printf("hello, world\n"); #ifdef __DJGPP__ printf("hello, djgpp\n"); #endif #ifdef __MSDOS__ printf("hello, dos\n"); #endif return 0; }