question

67664609 avatar image
0 Votes"
67664609 asked RLWA32-6355 published

Can use C++ Modules due to /Zc:twoPhase- even though I didn't specify it.

When I use VS2019 to compile following code in Debug-X86:

 import std.core;
 using namespace std;
 int main()
 {
  cout << "AMD yes." << endl;
 }

It says:
fatal error C1214: Modules conflict with non-standard behavior requested via '/Zc:twoPhase-'
But I never specify that option. And my Command Line in Properties is:

 /JMC /experimental:module /permissive- /MP /ifcOutput "Debug\" /GS /analyze- /W3 /Zc:wchar_t /ZI /Gm- /O2 /sdl /Fd"Debug\vc142.pdb" /Zc:inline /fp:precise /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_CRT_SECURE_NO_WARNINGS" /D "WXUSINGDLL" /D "_UNICODE" /D "UNICODE" /errorReport:prompt /WX- /Zc:forScope /Gd /Oy- /Oi /MDd /openmp- /std:c++latest /FC /Fa"Debug\" /EHsc /nologo /Fo"Debug\" /Fp"Debug\boostjson.pch" /diagnostics:column 


You can see there is no /Zc:twoPhase-.

Strangely if I compile in Release-X64, there is no problem. The Command Line is:

 /experimental:module /permissive- /ifcOutput "x64\Release\" /GS /GL /W3 /Gy /Zc:wchar_t /Zi /Gm- /O2 /sdl /Fd"x64\Release\vc142.pdb" /Zc:inline /fp:precise /D "NDEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /errorReport:prompt /WX- /Zc:forScope /Gd /Oi /MD /openmp- /std:c++latest /FC /Fa"x64\Release\" /EHsc /nologo /Fo"x64\Release\" /Fp"x64\Release\boostjson.pch" /diagnostics:column 

Also there is the same problem in Release-X86:

    /experimental:module /permissive- /ifcOutput "Release\" /GS /GL /analyze- /W3 /Gy /Zc:wchar_t /Zi /Gm- /O2 /sdl /Fd"Release\vc142.pdb" /Zc:inline /fp:precise /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_CRT_SECURE_NO_WARNINGS" /D "WXUSINGDLL" /D "_UNICODE" /D "UNICODE" /errorReport:prompt /WX- /Zc:forScope /Gd /Oy- /Oi /MD /openmp- /std:c++latest /FC /Fa"Release\" /EHsc /nologo /Fo"Release\" /Fp"Release\boostjson.pch" /diagnostics:column 
c++
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

RLWA32-6355 avatar image
0 Votes"
RLWA32-6355 answered RLWA32-6355 published

I could not reproduce the issue with VS2019 16.11.5 in debug and release builds for both x86 and x64. I started with an Empty project and added a source file into which I pasted the posted code. The only changes that I made to project options across all configurations/platforms were to set /std:c++latest and /experimental:module.

Each build completed successfully although warning messages were issued by the compiler.

x86 - Debug build output -

 Build started...
 1>------ Build started: Project: ModuleTest, Configuration: Debug Win32 ------
 1>Source.cpp
 1>C:\Users\RLWA32\source\repos\ModuleTest\ModuleTest\Source.cpp(1,16): warning C5050: Possible incompatible environment while importing module 'std.core': _GUARDOVERFLOW_CRT_ALLOCATORS=1 is defined in current command line and not in module command line
 1>C:\Users\RLWA32\source\repos\ModuleTest\ModuleTest\Source.cpp(1,16): warning C5050: Possible incompatible environment while importing module 'std.core': _DEBUG is defined in current command line and not in module command line
 1>C:\Users\RLWA32\source\repos\ModuleTest\ModuleTest\Source.cpp(1,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
 1>   Creating library C:\Users\RLWA32\source\repos\ModuleTest\Debug\ModuleTest.lib and object C:\Users\RLWA32\source\repos\ModuleTest\Debug\ModuleTest.exp
 1>ModuleTest.vcxproj -> C:\Users\RLWA32\source\repos\ModuleTest\Debug\ModuleTest.exe
 1>Done building project "ModuleTest.vcxproj".
 ========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

x86 Debug Command line -

 /JMC /experimental:module /permissive- /ifcOutput "Debug\" /GS /analyze- /W3 /Zc:wchar_t /ZI /Gm- /Od /sdl /Fd"Debug\vc142.pdb" /Zc:inline /fp:precise /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /errorReport:prompt /WX- /Zc:forScope /RTC1 /Gd /Oy- /MDd /std:c++latest /FC /Fa"Debug\" /EHsc /nologo /Fo"Debug\" /Fp"Debug\ModuleTest.pch" /diagnostics:column 

x86 Release Build Output

 Build started...
 1>------ Build started: Project: ModuleTest, Configuration: Release Win32 ------
 1>Source.cpp
 1>C:\Users\RLWA32\source\repos\ModuleTest\ModuleTest\Source.cpp(1,16): warning C5050: Possible incompatible environment while importing module 'std.core': _GUARDOVERFLOW_CRT_ALLOCATORS=1 is defined in current command line and not in module command line
 1>C:\Users\RLWA32\source\repos\ModuleTest\ModuleTest\Source.cpp(1,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
 1>   Creating library C:\Users\RLWA32\source\repos\ModuleTest\Release\ModuleTest.lib and object C:\Users\RLWA32\source\repos\ModuleTest\Release\ModuleTest.exp
 1>Generating code
 1>Previous IPDB not found, fall back to full compilation.
 1>All 6 functions were compiled because no usable IPDB/IOBJ from previous compilation was found.
 1>Finished generating code
 1>ModuleTest.vcxproj -> C:\Users\RLWA32\source\repos\ModuleTest\Release\ModuleTest.exe
 1>Done building project "ModuleTest.vcxproj".
 ========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

x86 Release Command line -

 /experimental:module /permissive- /ifcOutput "Release\" /GS /GL /analyze- /W3 /Gy /Zc:wchar_t /Zi /Gm- /O2 /sdl /Fd"Release\vc142.pdb" /Zc:inline /fp:precise /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /errorReport:prompt /WX- /Zc:forScope /Gd /Oy- /Oi /MD /std:c++latest /FC /Fa"Release\" /EHsc /nologo /Fo"Release\" /Fp"Release\ModuleTest.pch" /diagnostics:column 
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.