jorgen / json_struct

json_struct is a single header only C++ library for parsing JSON directly to C++ structs and vice versa
Other
422 stars 57 forks source link

min and max ? #26

Closed yanzixiang closed 2 years ago

yanzixiang commented 2 years ago
#if defined(min) || defined(max)

#error min or max macro is defined. Make sure these are not defined before including json_struct.h.\
 Use "#define NOMINMAX 1" before including Windows.h
#endif

I have #define NOMINMAX 1, but I can NOT compile this either,

using vs 2022 and qt5. How can I find where are minx and max macro is defined and disable it ?

yanzixiang commented 2 years ago

undef min

undef max

make it to compile,but I thinks it is not the right way, can anyone give me a better way ?

jorgen commented 2 years ago

You can add /DNOMINMAX=1 as a compiler flag or you can include json_struct.h. Or you define #define NOMINMAX 1 at the top of the cpp files it should also work. You could include json_struct.h before you include Qt or any other header. I had a quick look at the Qt headers and it seems they are defining NOMINMAX before including Windows.h.

jorgen commented 2 years ago