imneme / pcg-cpp

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

Another MSVC compiler problem with pcg32 vs pcg64 #70

Closed eike-fokken closed 3 years ago

eike-fokken commented 3 years ago

Hi there!

I'm trying to use pcg64 in my program (first question: should I? When is pcg32 enough?) When I do that I get the following compiler error with MSVC 19:

 error C2678: binary '<<': no operator found which takes a left-hand operand of type 'dest_t' (or there is no acceptable conversion) [C:\Users\Eike\Documents\grazer\build\src\Auxillary\Mathfunctions\mathfunctions.vcxproj]

 message : could be 'std::ostream &pcg_extras::operator <<(std::ostream &,uint8_t)' [found using argument-dependent lookup] [C:\Users\Eike\Documents\grazer\build\src\Auxillary\Mathfunctions\mathfunctions.vcxproj]
C:\Users\Eike\Documents\grazer\pcg\include\pcg_uint128.hpp(774,3): message : or       'pcg_extras::uint_x4<uint32_t,uint64_t> pcg_extras::operator <<<uint32_t,uint64_t>(const pcg_extras::uint_x4<uint32_t,uint64_t> &,const pcg_extras::bitcount_t)' [C:\Users\Eike\Documents\grazer\build\src\Auxillary\Mathfunctions\mathfunctions.vcxproj]
C:\Users\Eike\Documents\grazer\pcg\include\pcg_extras.hpp(425,1): message : or       'built-in C++ operator<<(UIntX2, UIntX2)' [C:\Users\Eike\Documents\grazer\build\src\Auxillary\Mathfunctions\mathfunctions.vcxproj]
          with
          [
              UIntX2=uint64_t
          ]

Note that the line numbers are probably wrong, because I clang-formated the sourcecode inadvertedly.

The same compiles without issue with pcg32. I guess I would have to supply an additional overload for << but I don't know how. Can someone help me?

eike-fokken commented 3 years ago

Note that the same goes through without issue on both clang and gcc.

lemire commented 3 years ago

@eike-fokken I recommend to avoid unnecessarily modifying the code of a dependency. If you must modify it, I recommend you use a patch instead.

eike-fokken commented 3 years ago

A pull request would be the way to go, I guess. Its just that i don't know how to write it.

lemire commented 3 years ago

A pull request would be the way to go, I guess. Its just that i don't know how to write it.

Why would you issue a pull request? Do you have a patch for the issue that you have found?

eike-fokken commented 3 years ago

Not yet. But as soon as i have i will file a pull request.

eike-fokken commented 3 years ago

I realize that I just don't know enough c++ to fix my issue. I guess I'll stick with pcg32 for now.

imneme commented 3 years ago

I checked on Visual Studio 2019 and I don't see any issues using << with pcg64. When reporting an issue, please provide a short test program that shows the purported problem, rather than just an error message you got compiling your own larger codebase.

eike-fokken commented 3 years ago

I don't know, what happened. Now that I tried to reproduce the issue I failed to do so. Once again sorry for bothering you.