News for hackers. Stuff that matters.
Re:Deciphering C++ compiler errors: Nonsensical errors from ... by aleden on Thursday December 12, 2024 @12:46AM (#42396567)
Before #define ing MY_MACRO, do

#ifdef MY_MACRO

#error

#endif

edit: and #undef MY_MACRO after done using it, ideally.

Re:Deciphering C++ compiler errors: Nonsensical errors from ... by AlotOfReading on Thursday December 12, 2024 @01:39AM (#42396804)
Not a perfect defense either. If you ever have the misfortune of using mentor graphics code, they #define REGISTER. They also ship a standard library that uses the register keyword. If you build a project using their standard library and their toolchain together, it explodes. If you name something like set_register, it also explodes.