Re: INT_MIN and compiler diagnostic



Beej Jorgensen <beej@xxxxxxx> writes:
[...]
(Interestingly, though, I guess I expected the preprocessor to calculate
the final answer before passing it to the compiler, and it doesn't.

And now, it doesn't even make sense that the preprocessor would do it.
I mean, the compiler has to do that kind of stuff anyway, right?

So why did I have it in the back of my mind that the preprocessor
sometimes did simple math? Some holdover from the olden days of not-so-
optimal compilers?)
[...]

The preprocessor does do simple math within preprocessor directives.
For example:

#if 2 + 2 == 4

is evaluated by the preprocessor.

Arithmetic expressions outside preprocessor directives may be (and in
some cases, must be) evaluated at compilation time, but not during the
preprocessing phases.

--
Keith Thompson (The_Other_Keith) kst-u@xxxxxxx <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
.



Relevant Pages

  • Re: #define and (brackets)
    ... The compiler doesn't second-guess. ... STRIZE is passed a value x as NUM. ... The preprocessor again creates ... it must evaluate the macro but this time instead of #NUM ...
    (microsoft.public.vc.language)
  • Re: more compiler switches
    ... Also print the version number of the compiler ... driver program and of the preprocessor and the compiler proper. ... C source code which should not be preprocessed. ... Like -v except the commands are not executed and all command arguments are ...
    (comp.lang.fortran)
  • Re: SmallC
    ... Well, I tried a bootstrap. ... I thought I'd notice much more missing from the preprocessor, ... compiler tests for some time. ... don't have alot of confidence in small-c's parser, ...
    (alt.lang.asm)
  • Re: Wheres the beef?
    ... > Is it possible to define a macro substitution in the C++ preprocessor so ... > heavily invested in MFC, and certain capabilities (Class Wizard & Browser ... > see is viable is by accommodating the compiler differences in compiler ... > I need to be able to call in different header files depending on the version ...
    (microsoft.public.vsnet.ide)
  • Re: setting macro
    ... >> #define DEBUG ... > The preprocessor and compiler are two distinct systems so by the time the ... Unless the #ifdef section is part ...
    (comp.lang.c)