InsightSoftwareConsortium / ITK

Insight Toolkit (ITK) -- Official Repository. ITK builds on a proven, spatially-oriented architecture for processing, segmentation, and registration of scientific images in two, three, or more dimensions.
https://itk.org
Apache License 2.0
1.43k stars 665 forks source link

ITK build failed on MSVC + permissive- on windows #235

Closed QuellaZhang closed 5 years ago

QuellaZhang commented 5 years ago

ITK failed when build with /permissive- by msvc on Windows, I use latset version b95b4c4 on master branch. Could you please help look at this?

You can repro this issue as the steps below:

  1. git clone http://itk.org/ITK.git D:\ITK\src
  2. open VS2017 x86 command prompt as admin and browse to D:\ITK
  3. set CL=/D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING /permissive- /Zc:twoPhase-
  4. mkdir build_x86 && pushd build_x86
  5. cmake -G "Visual Studio 15 2017" -DCMAKE_SYSTEM_VERSION=10.0.17134.0 -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTING=ON -DBUILD_EXAMPLES=OFF ..\src\
  6. msbuild /m /p:Configuration=Release;Platform=Win32 All_BUILD.vcxproj /t:Rebuild

Failures: D:\ITK\src\Modules\ThirdParty\GDCM\src\gdcm\Source\Common\gdcmCAPICryptographicMessageSyntax.cxx(369,1): error C2362: initialization of 'nrOfRecipientsLen' is skipped by 'goto err' err: ^ D:\ITK\src\Modules\ThirdParty\GDCM\src\gdcm\Source\Common\gdcmCAPICryptographicMessageSyntax.cxx(247): note: see declaration of 'nrOfRecipientsLen' DWORD nrOfRecipeints, nrOfRecipientsLen = sizeof(DWORD); D:\ITK\src\Modules\ThirdParty\GDCM\src\gdcm\Source\Common\gdcmCAPICryptographicMessageSyntax.cxx(369): note: see declaration of 'err' err: D:\ITK\src\Modules\ThirdParty\GDCM\src\gdcm\Source\Common\gdcmCAPICryptographicMessageSyntax.cxx(369,1): error C2362: initialization of 'kekAlgLen' is skipped by 'goto err' err: ^ D:\ITK\src\Modules\ThirdParty\GDCM\src\gdcm\Source\Common\gdcmCAPICryptographicMessageSyntax.cxx(235): note: see declaration of 'kekAlgLen' DWORD kekAlgLen = sizeof(ALG_ID); D:\ITK\src\Modules\ThirdParty\GDCM\src\gdcm\Source\Common\gdcmCAPICryptographicMessageSyntax.cxx(369): note: see declaration of 'err' err: D:\ITK\src\Modules\ThirdParty\GDCM\src\gdcm\Source\Common\gdcmCAPICryptographicMessageSyntax.cxx(369,1): error C2362: initialization of 'cbMessageTypeLen' is skipped by 'goto err' err: ^ D:\ITK\src\Modules\ThirdParty\GDCM\src\gdcm\Source\Common\gdcmCAPICryptographicMessageSyntax.cxx(221): note: see declaration of 'cbMessageTypeLen' DWORD dwMessageType, cbMessageTypeLen = sizeof(DWORD); D:\ITK\src\Modules\ThirdParty\GDCM\src\gdcm\Source\Common\gdcmCAPICryptographicMessageSyntax.cxx(369): note: see declaration of 'err' err:

thewtex commented 5 years ago

@QuellaZhang thanks for the report.

The path forward is to merge a patch into upstream GDCM for the release branch, then we will merge it into ITK.

It sounds like a refactor to remove goto could help.

CC: @malaterre

dzenanz commented 5 years ago

You are not only disabling permissive mode (meaning enabling standards conformance mode), but you are at the same time disabling two-phase lookup. The errors from GDCM library are appearing because it is one of the base libraries in the dependency graph. If those errors are fixed, I would be surprised if no new errors appeared somewhere else. Removing goto statements would be nice, but I don't think that will be the end of it.

QuellaZhang commented 5 years ago

Hello, any updates?

dzenanz commented 5 years ago

261 should take care of compiling in conformance mode (/permissive-).

Why do you want to disable two-phase lookup?

dzenanz commented 5 years ago

It turns out that adding the switch /Zc:twoPhase- made no difference after #261 was merged. Closing the issue as fixed.