Skip to content

fix issues with MSVC#637

Open
h-vetinari wants to merge 1 commit into
google:masterfrom
h-vetinari:msvc
Open

fix issues with MSVC#637
h-vetinari wants to merge 1 commit into
google:masterfrom
h-vetinari:msvc

Conversation

@h-vetinari

Copy link
Copy Markdown

While working on conda-forge/s2geometry-feedstock#35, I ran into three separate issues with MSVC which are all fixed here.

Problem 1: constexpr

%SRC_DIR%\src\s2\util\math\exactfloat\bignum.cc(96): error C3493: 'kMaxChunkDigits' cannot be implicitly captured because no default capture mode has been specified

fixed by making kMaxChunkDigits be of static storage duration

Problem 2: namespace confusion between C(++) stdlib vs. ExactFloat implementations

│ │ FAILED: [code=2] CMakeFiles/s2.dir/src/s2/util/math/exactfloat/exactfloat.cc.obj
│ │ C:\PROGRA~1\MICROS~2\2022\ENTERP~1\VC\Tools\MSVC\1444~1.352\bin\Hostx64\x64\cl.exe /nologo /TP -DABSL_CONSUME_DLL -DABSL_MIN_LOG_LEVEL=1 -DNOMINMAX -DS2GEOMETRY_BUILDING_S2GEOMETRY -D_USE_MATH_DEFINES -Ds2_EXPORTS -I%SRC_DIR%\src -external:I%PREFIX%\Library\include -external:W0 /DWIN32 /D_WINDOWS /GR /EHsc /O2 /Ob2 /DNDEBUG -std:c++17 -MD -J /showIncludes /FoCMakeFiles\s2.dir\src\s2\util\math\exactfloat\exactfloat.cc.obj /FdCMakeFiles\s2.dir\ /FS -c %SRC_DIR%\src\s2\util\math\exactfloat\exactfloat.cc
│ │ %SRC_DIR%\src\s2\util\math\exactfloat\exactfloat.cc(59): error C2440: 'initializing': cannot convert from 'exactfloat::ExactFloat' to 'double'
│ │ %SRC_DIR%\src\s2\util\math\exactfloat\exactfloat.cc(59): note: No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
│ │ %SRC_DIR%\src\s2\util\math\exactfloat\exactfloat.cc(60): error C2440: 'static_cast': cannot convert from 'exactfloat::ExactFloat' to 'uint64_t'
│ │ %SRC_DIR%\src\s2\util\math\exactfloat\exactfloat.cc(60): note: No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
│ │ %SRC_DIR%\src\s2\util\math\exactfloat\exactfloat.cc(149): error C2440: 'return': cannot convert from 'exactfloat::ExactFloat' to 'double'
│ │ %SRC_DIR%\src\s2\util\math\exactfloat\exactfloat.cc(149): note: No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called

Fixed by qualifying the respective calls with std:: (since <cmath> is already included)

Problem 3: std::from_chars for integers takes pointers, not iterators

 │ │ FAILED: [code=2] CMakeFiles/s2.dir/src/s2/util/math/exactfloat/bignum.cc.obj 
 │ │ C:\PROGRA~1\MICROS~2\2022\ENTERP~1\VC\Tools\MSVC\1444~1.352\bin\Hostx64\x64\cl.exe  /nologo /TP -DABSL_CONSUME_DLL -DABSL_MIN_LOG_LEVEL=1 -DNOMINMAX -DS2GEOMETRY_BUILDING_S2GEOMETRY -D_USE_MATH_DEFINES -Ds2_EXPORTS -I%SRC_DIR%\src -external:I%PREFIX%\Library\include -external:W0 /DWIN32 /D_WINDOWS /GR /EHsc /O2 /Ob2 /DNDEBUG -std:c++17 -MD   -J /showIncludes /FoCMakeFiles\s2.dir\src\s2\util\math\exactfloat\bignum.cc.obj /FdCMakeFiles\s2.dir\ /FS -c %SRC_DIR%\src\s2\util\math\exactfloat\bignum.cc
 │ │ %SRC_DIR%\src\s2\util\math\exactfloat\bignum.cc(124): error C2665: 'std::from_chars': no overloaded function could convert all the argument types
 │ │ C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.44.35207\include\charconv(1960): note: could be 'std::from_chars_result std::from_chars(const char *const ,const char *const ,long double &,const std::chars_format) noexcept'
 │ │ %SRC_DIR%\src\s2\util\math\exactfloat\bignum.cc(124): note: 'std::from_chars_result std::from_chars(const char *const ,const char *const ,long double &,const std::chars_format) noexcept': cannot convert argument 1 from 'std::_String_view_iterator<_Traits>' to 'const char *const '
 │ │         with
 │ │         [
 │ │             _Traits=std::char_traits<char>
 │ │         ]

Fixed by using pointers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant