imneme / pcg-cpp

PCG — C++ Implementation
Apache License 2.0
745 stars 99 forks source link

Unable to determine target endianness on Visual Studio 16.7.3 #63

Closed acgetchell closed 3 years ago

acgetchell commented 4 years ago

When compiling with Visual Studio 16.7.3 on Windows 10 version 2004 I get #error: Unable to determine target endianness on line 74 of pcg_uint128.hpp.

Would it be appropriate to use BOOST_ENDIAN to replace the code in lines 55 - 76?

lemire commented 4 years ago

You are using Windows 10 and Visual Studio, yet neither _M_X64 nor _M_IX86 are defined? Are you compiling for ARM?

Would it be appropriate to use BOOST_ENDIAN to replace the code in lines 55 - 76?

Maybe I am misunderstanding your comment, but are you suggesting that Boost be made a dependency of this single-header library just to identify endianness?

When including the header in question, you can specify __LITTLE_ENDIAN__ or the reverse if the heuristic that Melissa uses fails.

acgetchell commented 4 years ago

You are using Windows 10 and Visual Studio, yet neither _M_X64 nor _M_IX86 are defined? Are you compiling for ARM?

No, I have an Intel Core i9, and I could compile this on Visual Studio a few weeks ago.

Would it be appropriate to use BOOST_ENDIAN to replace the code in lines 55 - 76?

Maybe I am misunderstanding your comment, but are you suggesting that Boost be made a dependency of this single-header library just to identify endianness?

I was suggesting that if someone were using Boost (as I am) along with this library, that their facility be used.

That's easier to do using CMake (which can detect the presence of Boost), and as I understand it, there's a long standing pull request (https://github.com/imneme/pcg-cpp/pull/44) to do just that.

When including the header in question, you can specify __LITTLE_ENDIAN__ or the reverse if the heuristic that Melissa uses fails.

Thank you!

lemire commented 4 years ago

No, I have an Intel Core i9, and I could compile this on Visual Studio a few weeks ago.

You could use an Intel system to build for ARM but then you could not run your code natively. I suspect that you are compiling and running on your own machine. If so, I would expect that either _M_X64 or _M_IX86 would be defined.

Look at what the Microsoft documentation says...

_M_IX86 Defined as the integer literal value 600 for compilations that target x86 processors. This macro isn't defined for x64 or ARM compilation targets.
_M_X64 Defined as the integer literal value 100 for compilations that target x64 processors. Otherwise, undefine

Surely you are either targeting x86 or x64.

I believe that, by default, with Visual Studio 2019, you would be targeting x64... unless you, somehow, have a 32-bit Windows 10. So _M_X64 ought to be defined.

imneme commented 3 years ago

Closed since issue couldn't be reproduced.