minetest / irrlicht

Minetest's fork of Irrlicht

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

minetest failed to build with error C2589, error C3878, error C2760 with MSVC under /permissive- mode on Windows

Zhaojun-Liu opened this issue · comments

Minetest version
commit is 7ffc0268dfd78647187554d6248015329e9f5d2d
OS / Hardware

Operating system: Windows server 2019
CPU:

GPU model:
OpenGL version:

Summary

Minetest failed to build with error C2589, error C3878, error C2760 with MSVC under /permissive- mode on Windows. The commit we use is 7ffc0268dfd78647187554d6248015329e9f5d2d. Could you please take a look? Thanks.

VS version: VS2019 (16.11.11)
OS: Windwos server 2019

Steps to reproduce
  1. git clone https://github.com/minetest/minetest F:\gitP\minetest\minetest and cd F:\gitP\minetest\minetest
  2. xcopy F:\gitP\minetest\irrlicht F:\gitP\minetest\minetest\lib\irrlichtmt /k/r/e/i/s/c/h/f/y
  3. cd F:\gitP\Microsoft\vcpkg and bootstrap-vcpkg.bat 2>&1
  4. vcpkg.exe install --recurse zlib zstd curl[winssl] openal-soft libvorbis libogg sqlite3 freetype luajit gmp jsoncpp libjpeg-turbo --triplet x64-windows --clean-after-build 2>&1
  5. mkdir F:\gitP\minetest\minetest\build_amd64 and cd F:\gitP\minetest\minetest\build_amd64
  6. cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_SYSTEM_VERSION=10.0.18362.0 -DCMAKE_BUILD_TYPE=Release -DENABLE_GETTEXT=OFF -DENABLE_CURSES=OFF -DCMAKE_TOOLCHAIN_FILE=F:\gitP\Microsoft\vcpkg\scripts\buildsystems\vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows .. 2>&1
  7. set CL= /permissive-
  8. mkdir F:\gitP\minetest\minetest\sdklocaltools and cd F:\gitP\minetest\minetest\sdklocaltools
  9. set PATH=F:\tools\build2\bin;%PATH%
  10. curl https://www.khronos.org/registry/OpenGL/api/GL/glext.h -O -L 2>&1
    curl https://www.khronos.org/registry/OpenGL/api/GL/glcorearb.h -O -L 2>&1
    curl https://www.khronos.org/registry/OpenGL/api/GL/glxext.h -O -L 2>&1
    curl https://www.khronos.org/registry/OpenGL/api/GL/wglext.h -O -L 2>&1
  11. xcopy F:\gitP\minetest\minetest\sdklocaltools "C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\gl" /k/r/e/i/s/c/h/f/y
  12. cd F:\gitP\minetest\minetest\build_amd64
  13. msbuild /m /p:Platform=x64 /p:Configuration=Release minetest.sln /t:Rebuild 2>&1
Excepted result:

build successfully.

Actual result:
F:\gitP\minetest\minetest\lib\irrlichtmt\include\irrArray.h(397,16): error C2589: '(': illegal token on right side of '::' [F:\gitP\minetest\minetest\build_amd64\lib\irrlichtmt\source\Irrlicht\IRROTHEROBJ.vcxproj]
        F:\gitP\minetest\minetest\lib\irrlichtmt\include\irrArray.h(397,16): error C3878: syntax error: unexpected token '(' following 'expression' [F:\gitP\minetest\minetest\build_amd64\lib\irrlichtmt\source\Irrlicht\IRROTHEROBJ.vcxproj]
        F:\gitP\minetest\minetest\lib\irrlichtmt\include\irrArray.h(397,16): error C2760: syntax error: ')' was unexpected here; expected ';' [F:\gitP\minetest\minetest\build_amd64\lib\irrlichtmt\source\Irrlicht\IRROTHEROBJ.vcxproj]
        F:\gitP\minetest\minetest\lib\irrlichtmt\include\irrArray.h(397,16): error C3878: syntax error: unexpected token ')' following 'expression_statement' [F:\gitP\minetest\minetest\build_amd64\lib\irrlichtmt\source\Irrlicht\IRROTHEROBJ.vcxproj]
        F:\gitP\minetest\minetest\lib\irrlichtmt\include\irrArray.h(397,16): error C2760: syntax error: ':' was unexpected here; expected ';' [F:\gitP\minetest\minetest\build_amd64\lib\irrlichtmt\source\Irrlicht\IRROTHEROBJ.vcxproj]
        F:\gitP\minetest\minetest\lib\irrlichtmt\include\irrArray.h(397,16): error C3878: syntax error: unexpected token ':' following 'expression_statement' [F:\gitP\minetest\minetest\build_amd64\lib\irrlichtmt\source\Irrlicht\IRROTHEROBJ.vcxproj]
Detailed log:

build.log

commented

We have Visual Studio builds in our CI and they run fine.
Does removing /permissive- from the flags make a difference?

It looks like VS has a problem with std::min here, replacing this with core::min_ might also help.

@sfan5 the issue just occurs with option /permissive-. And the root reason is that the source includes windows.h which defines the macro 'min' and 'max'. It needs to define the macro 'NOMINMAX' before include windows.h.