min and max macros
tnevolin opened this issue · 4 comments
#define min(x, y) std::min(x, y)
#define max(x, y) std::max(x, y)
These macros are very fragile. I am sure it compiles in your environment since you were able to release. However, any shift in includes or their sequence may trigger the double substitution problem.
max(x, y) => std::max(x, y) => std::std::max(x, y)
I understand that your code comes at no warranty and I am the only one who can suffer from this downstream.
😃
However, if not much trouble, would you mind to either use std:: calls directly as is or rename the macro to be lexically distinct from function name you substitute?
Like, for example:
#define MIN(x, y) std::min(x, y)
Well, being that they are used in hundreds of lines now changing them would become cumbersome. So I'm not sure.
I actually wonder how you made it work provided you have max definition and in the same file. My uses hashtable.h that uses std::max that gets substituted by this macro. Is yours different?
I would just recommend arranging the headers in such a way that the problem does not occur. By default it compiles fine.
I have tried.