Mail Archives: djgpp/1996/02/10/09:24:57
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 -