Re:Dennis Ritchie's first C compiler on Github
by yoklov on Wednesday May 22, 2013 @08:00AM
(#5750150)
I'm fairly certain that shadowing a keyword with a macro is forbidden by the standard (or invokes UB?) but this will still work for most compilers, provided LET is defined reasonably. Hm, something like
may be reasonable, though tokenpasting in __LINE__ for good measure might be necessary for nesting.
[ Parent
| on HN ]
Re:Dennis Ritchie's first C compiler on Github
by 30thElement on Wednesday May 22, 2013 @09:59AM
(#5750850)
Shadowing keywords is perfectly valid, although I believe you can't shadow keywords in standard headers so that compiler writers don't need to worry about it. It gives rise to some "useful" C/C++ features that should never be used, like if you want to access private members in foo.cpp, do
#define private public
#include "foo.cpp"
#undef private
Re:Dennis Ritchie's first C compiler on Github
by TazeTSchnitzel on Wednesday May 22, 2013 @12:24PM
(#5751908)
I can imagine some insidious menace adding this to the top of a file:
#define public protected