Re: #define and (brackets)
"Alan Carre" <alan@twilightgames.com> wrote in message
news:e$8mm$XUJHA.4168@TK2MSFTNGP02.phx.gbl
"Igor Tandetnik" <itandetnik@mvps.org> wrote in message
news:OsZwtwXUJHA.4168@TK2MSFTNGP02.phx.gbl...
You yourself show the compiler contradicting itself (the same code
compiles directly, but fails to compile if preprocessed first), and
agree there's a bug somewhere. You cannot then proceed to hold the
behavior of a known-buggy compiler as proof of any facts about the
C++ language. You have to argue from first principles - in this
case, from
I'm not asserting any facts about the C++ language.
You don't? Didn't you claim, in essence, that this program shouldn't
compile ("Thanks cl.exe I wanted an error!"):
#define X -1
int main()
{
return -X;
}
I don't know if I want a "smart" pre-processor. I want it to do
EXACTLY what I tell it to do.
And it does. It's just that you are telling it something different than
what you think you do. See also http://en.wikipedia.org/wiki/DWIM
If I make a mistake, I want an error to
come out.
I'd love to live in such a world, too. Just to think, I'd never have to
touch a debugger again! Heck, if the compiler knows enough to tell me
whenever I make a mistake, why can't it just write the damn program for
me?
Upon further consideration, no, I don't want to live in such a world. My
employment prospects would be rather grim.
Also, I do believe the compiler is in error for "accepting" -NUM, not
for rejecting the preprocessor's interpretation
You believe incorrectly.
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925