Re: More keyword abomination by C++0x
Andre Kaufmann wrote:
I agree that it's not a good idea to replace keywords, although for
debugging purposes this sometimes can't be avoided.
E.g. Comeau online happily compiles:
#include <cstdio>
#define delete(a) std::printf(a)
int main(int argc, char* argv[])
{
delete ("hello");
return 0;
}
The behavior is undefined. What is the compiler supposed to do? :-)
And even my edition of "The C++ Programming Language" says that the
preprocessor is rather dumb and doesn't know anything about C++
syntax and C++ keywords.
That might be true, but it is the rest of the compiler that gets into
trouble when compiling the preprocessed code.
Consider what happens here:
#include <cstdio>
#define delete(a) std::printf(a)
#include <vector>
Not likely to work very well!
Is that requirement new ? Then it would break much old (debug) code.
It has been there all the time.
Bo Persson
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]