Closed Andersama closed 1 year ago
Thanks for bringing it up. I personally think that it is not worth the effort to implement mitigations for these long-shunned practices. OTOH we could add a preprocessor check which explicitly #error
s out if min/max have been redefined.
I'm just glad that shuffling the include produced different errors which eventually lead me to figure out what lines were a problem, was a pretty strange experience including a library in a test project where it worked and then bringing it elsewhere for it to generate a compiler internal error.
I assume it was the windows headers which did this? They're the usual culprit.
They can be ordered to not defined min or max using an opt out macro.
@ned14 Pretty certain you're right that it was the windows headers buried somewhere. A compiler internal error was a first, usually the replacement makes for an obvious error the compiler should pick up on, this was strange. I wish compiler internal errors came with some additional feedback, the only thing we can know for certain is some macro replacement of min/max somewhere threw the compiler for a loop.
The project suffers the classic min/max define problem. Currently on projects which may have accidentally defined min/max as a macro the compiler can't properly parse the header. It may be worth refactoring std::min and std::max out of the project, alternatively be sure to guard against min and max preprocessor defines.