jarro2783 / cxxopts

Lightweight C++ command line option parser
MIT License
4.25k stars 590 forks source link

Failure to include cxxopts on MSVC v143 with `std.core` module import #367

Closed IlleQuiProgrammat closed 2 years ago

IlleQuiProgrammat commented 2 years ago

I received the following error when attempting to compile a basic project:

C:\Users\<user>\source\repos\<org>\<proj>\src\<proj>.cpp(2,16): warning C5050: Possible incompatible environment while importing module 'std.core': _M_FP_PRECISE is defined in current command line and not in module command line 
C:\Users\<user>\source\repos\<org>\<proj>\src\<proj>.cpp(2,16): warning C5050: Possible incompatible environment while importing module 'std.core': mismatched C++ versions.  Current "202002" module version "202004" 
D:\a\_work\1\s\binaries\x86ret\inc\memory(3473,30): error C2475: 'std::operator ==': redefinition; 'constexpr' specifier mismatch 
  C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629\include\memory(3473): message : see declaration of 'std::operator ==' [C:\Users\<user>\source\repos\<org>\<proj>\out\build\vcpkg-x64-debug\src\<proj>.vcxproj]
  C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629\include\vector(776): message : while compiling class template member function 'std::vector<std::string,std::allocator<std::string>> &std::vector<std::string,std::allocator<std::string>>::operator =(std::vector<std::string,std::allocator<std::string>> &&) noexcept' [C:\Users\<user>\source\repos\<org>\<proj>\out\build\vcpkg-x64-debug\src\<proj>.vcxproj]
  C:\Users\<user>\source\repos\<org>\<proj>\out\build\vcpkg-x64-debug\vcpkg_installed\x64-windows\include\cxxopts.hpp(2166): message : see reference to function template instantiation 'std::vector<std::string,std::allocator<std::string>> &std::vector<std::string,std::allocator<std::string>>::operator =(std::vector<std::string,std::allocator<std::string>> &&) noexcept' being compiled [C:\Users\<user>\source\repos\<org>\<proj>\out\build\vcpkg-x64-debug\src\<proj>.vcxproj]
  C:\Users\<user>\source\repos\<org>\<proj>\out\build\vcpkg-x64-debug\vcpkg_installed\x64-windows\include\cxxopts.hpp(1530): message : see reference to class template instantiation 'std::vector<std::string,std::allocator<std::string>>' being compiled [C:\Users\<user>\source\repos\<org>\<proj>\out\build\vcpkg-x64-debug\src\<proj>.vcxproj]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629\include\vector(784,1): fatal error C1907: unable to recover from previous error(s); stopping compilation 
    INTERNAL COMPILER ERROR in 'C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629\bin\HostX64\x64\CL.exe'
        Please choose the Technical Support command on the Visual C++
        Help menu, or open the Technical Support help file for more information

The minimal sample is:

#include <cxxopts.hpp>
import std.core;

int main(int argc, const char** argv)
{
    return 0;
}

It is a CMake project on C++ 20 running with the 'Visual Studio 17 2022' build generator for CMake. Notable compilation option: /experimental:module is present to enable importation of std.core that bundles several of the std library headers.

As of yet I am not sure whether it is a bug in cxxopts or MSVC std lib. Any help would be appreciated.

jarro2783 commented 2 years ago

Given that module support is very experimental in all compilers I don't really know what I can do about this one.

IlleQuiProgrammat commented 2 years ago

Given that module support is very experimental in all compilers

It is supposed to have full support in MSVC other than the std.* modules which are experimental (and, annoyingly, seem to not be standard).

I don't really know what I can do about this one.

Understood, I will pass this onto MSVC to see if it's an issue on their end, especially seeing as it caused an internal error in the compiler.