News for hackers. Stuff that matters.
Re:In C++ modules globally unique module names seem to be un... by usrnm on Thursday October 02, 2025 @05:43AM (#45447778)
> 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.

Re:In C++ modules globally unique module names seem to be un... by 1718627440 on Thursday October 02, 2025 @05:56AM (#45447830)
Fair enough, but I wouldn't call this name conflict, this sounds more like incompatible code behaviour.
Re:In C++ modules globally unique module names seem to be un... by jasode on Thursday October 02, 2025 @06:10AM (#45447916)
>, 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+...

The "windows.h" is not "incompatible" code. It just has a name conflict that needs a workaround.

Re:In C++ modules globally unique module names seem to be un... by 1718627440 on Thursday October 02, 2025 @05:06PM (#45455563)
But 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.