www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/02/10/09:24:57

Xref: news2.mv.net comp.os.msdos.djgpp:935
From: alexlehm AT rbg DOT informatik DOT th-darmstadt DOT de (Alexander Lehmann)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: defines for djgpp V1.x and V2
Date: 6 Feb 1996 13:59:33 GMT
Organization: Technische Hochschule Darmstadt
Lines: 34
Message-ID: <4f7ms5$dd0@rs18.hrz.th-darmstadt.de>
References: <Pine DOT HPP DOT 3 DOT 91 DOT 960201175334 DOT 13778A-100000 AT santaka DOT sc-uni DOT ktu DOT lt> <Broeker DOT 823607325 AT axp04>
NNTP-Posting-Host: hp61.rbg.informatik.th-darmstadt.de
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Hans-Bernhard Broeker (Broeker AT axp04 DOT physik DOT rwth-aachen DOT de) wrote:
: Martynas Kunigelis <algikun AT santaka DOT sc-uni DOT ktu DOT lt> writes:

: >#if (DJGPP >= 2)
: ^^^^^^^^^^^^^^^^^

: But wouldn't that break if you try it with DJGPP V1? There, DJGPP isn't
: defined at all by default.  So poor old cpp would have to find out if
: "DJGPP" is larger or equal to "2".  Looking into the cpp manuals, I see
: that for undefined DJGPP, it is treated as being zero, and that works. 
: But there's at least one major multi-platform software package (gnuplot)
: that uses a "-DDJGPP" to flag that DJGPP is the actual platform.  That
: would mean cpp had to compare "" >= "2".  Looks like I have to return to
: base and re-read K&R and the cpp docs to find out what cpp does with
: such comparisons. 

If seems like cpp treats undefined identifiers in #ifs as causing the
condition to fail. If you write #if BLA > 1, then the #else part is
processed (so the construct works as expected), if you do it the other way
around #if BLA <= 1, it doesn't work.

If a cpp symbol is defined on the commandline -DBLA, the implicit definition
is #define BLA 1, so this works also, but it the symbol is defined in a header
file as #define BLA or if the command argument is -DBLA=, it causes a parse
error and the compilation fails.


bye, Alexander

--
Alexander Lehmann,                                  |  "On the Internet,
alex AT hal DOT rhein-main DOT de  (plain, MIME, NeXT)         |   nobody knows
alexlehm AT rbg DOT informatik DOT th-darmstadt DOT de (plain)     |   you're a dog."
<URL:http://www.student.informatik.th-darmstadt.de/~alexlehm/>

- Raw text -


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