-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Protect macro expansion of commonly defined macros #1337
Comments
I am not sure what this issue proposes - adding parentheses around |
Sorry if I was not clear. I was suggesting to do the same with I met the issue for |
Thanks for clarifying! I shall have a look. |
@SylvainCorlay Could you please check whether https://github.com/nlohmann/json/tree/feature/snprintf fixes the issue? |
@nlohmann thanks! I could check and it works perfectly! |
Thanks for the feedback! |
Thanks @nlohmann. And thanks for the great work on this library! |
Wrapping
std::min
andstd::max
in parentheses prevents the expansion of windows'min
andmax
macros. I agree these should have never existed in the first place, but that would allow windows users to make use ofnlohmann_json
without settingNOMINMAX
.Similarly,
Python.h
definessnprintf
as a macro. Wrapping calls in parentheses would also prevent the expansion of this macro.So the fix would be to replace instances of
std::snprintf
with(std::snprintf)
, similarly to what is done withstd::max
andstd::min
.The text was updated successfully, but these errors were encountered: