28 ms·
> and the compiler gives a warning/error about the redefinition That's if a macro conflicts with another macro, the real fun begins when a macro conflicts with
by usrnm 1y ago
> and the compiler gives a warning/error about the redefinition
That's if a macro conflicts with another macro, the real fun begins when a macro conflicts with something else in your code, and suddenly a piece of your code gets transparently replaced with something completely different. Granted, in most cases the result won't compile and you'll just spend some time scratching your head and staring at bizarre error messages, but one day you might get especially lucky and it will compile. Good luck debugging that.
- 1718627440 1y agoFair enough, but I wouldn't call this name conflict, this sounds more like incompatible code behaviour.
- jasode 1y ago>, but I wouldn't call this name conflict, this sounds more like incompatible code behaviour. It literally is a name conflict. It's not a DEBUGGER SYMBOL type of name conflict but it's still a name collision. A famous example of a macro name conflict is Microsoft windows.h ntdef.h min() max(): https://www.google.com/search?q=Microsoft+windows.h+min+max+macro+conflict https://www.google.com/search?q=Microsoft+windows.h+min+max+... The "windows.h" is not "incompatible" code. It just has a name conflict that needs a workaround.
- 1718627440 1y agoBut that's the kind of thing I addressed in my ancestor comment: a classic problem with different names clashing. You solve that by putting the translation unit boundaries somewhere else, or by undefining. Nothing else is pointed our in the Stackoverflow post appearing in your posted search query. It sounds a bit like some people have poor macro hygiene. I thought it's standard to just undefine all macros immediately after use.