So I came across this post today and read the "Redefining keywords section". I thought to myself: "No way, this just can't be true". But behold, it is valid gcc4.6 code:
#define private public
class A { private: int a; };
int main() { return A().a; }
$ g++ --version; g++ -o test test.cpp && ./test; echo $?
g++ (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
0
Funny, I saw someone use that exact #define when reading a post yesterday. Honestly, it doesn't surprise me.
I would never use such an ugly hack in real code though.
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches!
Yep, the preprocessor is ignorant of C/++ reserved words... Please, god, don't do this...
edit: btw, this is technically a C feature. And it's not really a feature. It's just a side-effect of the separation between preprocessor and compiler.