range-v3 icon indicating copy to clipboard operation
range-v3 copied to clipboard

Conflicts with win32 header files on visual studio 2022

Open OptimumCpp opened this issue 1 year ago • 2 comments

Compilation success depends on the order of includes. Fails if windows headers go 1st:

//compile failure:
#include <windows.h>
#include <range/v3/all.hpp>

The above code creates a lot of none-sence diagnostics. but if the order is reversed, everything works fine:

//compile success:
#include <range/v3/all.hpp>
#include <windows.h>

I guess the problem lies in ranges preprocessing. But since I am using external VCPKG, I cannot tell whether it is a problem on Microsoft port, or the ranges library has an issue.

thank you for making life easier.

OptimumCpp avatar Jun 21 '23 09:06 OptimumCpp

@OptimumCpp , you can add NOMINMAX preprocessor definition in the build system. After that, it should compile.

I also notice that sometimes, some libraries do #define True. In that case, it is worth doing #undef True before ranges inclusion.

przemkovv avatar Aug 14 '23 20:08 przemkovv

As I mentioned earlier, I mamged to build code with reordering includes, but I will try this workaround as well. But I guess True must be #undefd inside range headers.

OptimumCpp avatar Aug 14 '23 21:08 OptimumCpp