coreclr 빌드 시 error C3249: illegal statement or sub-expression for 'constexpr' function
github의 coreclr 소스 코드를 빌드하니 다음과 같은 오류를 내며 실패합니다.
c:\program files (x86)\windows kits\10\include\10.0.14393.0\winrt\windows.storage.h(13854): error C3249: illegal statement or sub-expression for 'constexpr' function (compiling source file E:\coreclr\src\gc\handletable.cpp) [E:\coreclr\bin\obj\Windows_NT.x64.Debug\src\gc\wks\gc_wks.vcxproj]
c:\program files (x86)\windows kits\10\include\10.0.14393.0\winrt\windows.storage.h(13895): error C3249: illegal statement or sub-expression for 'constexpr' function (compiling source file E:\coreclr\src\gc\handletable.cpp) [E:\coreclr\bin\obj\Windows_NT.x64.Debug\src\gc\wks\gc_wks.vcxproj]
이에 대해서 다음의 글에 활발한 토론이 있습니다.
Error when compiling with Windows 10 SDK 10.0.14393.0 #6642
; https://github.com/dotnet/coreclr/issues/6642
해결책으로 Windows SDK에 포함된 c:\Program Files (x86)\Windows Kits\10\Include\10.0.14393.0\um\winnt.h 파일을 변경하거나 coreclr에 포함된 debugreturn.h 파일을 변경하는 방법 등이 나오는데요. 제 경우에는 전자의 방법으로 처리했습니다. 즉, winnt.h 파일을 관리자 권한의 메모장으로 열어 아래와 같이 1900을 2900으로 변경해 주었습니다.
#if _MSC_VER >= 1900
#if _MSC_VER >= 2900
#define _ENUM_FLAG_CONSTEXPR constexpr
#else
#define _ENUM_FLAG_CONSTEXPR
#endif
참고로, Visual Studio 2015에서 C++ 프로젝트를 생성하면 관련 상숫값은 다음과 같습니다.
_MSC_VER == 1900
_MSC_BUILD == 1
_MSC_FULL_VER == 190024213
그러고 보니, 이 값은 cl.exe를 실행시켰을 때 출력되는 Compiler Version입니다.
C:\Program Files (x86)\Microsoft Visual Studio 14.0>cl
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24213.1 for x86
Copyright (C) Microsoft Corporation. All rights reserved.
usage: cl [ option... ] filename... [ /link linkoption... ]
어쨌든, 1900을 2900으로 바꾸는 것은 그다지 좋은 처리 방법으로는 보이지 않지만, _ENUM_FLAG_CONSTEXPR에 한정된 것이니만큼 크게 영향은 없을 듯하니 딱히 나빠 보이지도 않습니다. ^^
[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]