otland / forgottenserver

A free and open-source MMORPG server emulator written in C++
https://otland.net
GNU General Public License v2.0
1.59k stars 1.06k forks source link

Forgottenserver failed to build with error C2278 on Windows with option /std:c++latest #4556

Closed Zhaojun-Liu closed 7 months ago

Zhaojun-Liu commented 1 year ago

Before creating an issue, please ensure:

Hi, recently, the MSVC team updated the commit of Forgottenserver and vcpkg for RWC testing, and it build failed due to the F:\gitP\otland\forgottenserver\src\tools.h(77,25): error C2278: 'constant': unexpected token. Format is '__has_cpp_attribute( identifier )'. Could you please look this issue? Thanks.

Steps to reproduce (include any configuration/script required to reproduce)

  1. git clone https://github.com/otland/forgottenserver F:\gitP\otland\forgottenserver
  2. git clone https://github.com/Microsoft/vcpkg F:\gitP\Microsoft\vcpkg
  3. git -C "F:\gitP\Microsoft\vcpkg" reset --hard d99b693
  4. git -C "F:\gitP\otland\forgottenserver" reset --hard 419124f
  5. set CL= /std:c++latest
  6. cd F:\gitP\Microsoft\vcpkg
  7. bootstrap-vcpkg.bat
  8. vcpkg.exe install --recurse boost-iostreams boost-asio boost-system boost-filesystem boost-variant boost-lockfree luajit libmariadb pugixml cryptopp fmt --triplet x64-windows --clean-after-build
  9. mkdir F:\gitP\otland\forgottenserver\build_amd64 & cd F:\gitP\otland\forgottenserver\build_amd64
  10. cmake -G "Visual Studio 17 2022" -A x64 -DCMAKE_SYSTEM_VERSION=10.0.22621.0 -DCMAKE_BUILD_TYPE=Release -DMARIADB_LIBRARIES=F:/gitP/microsoft/vcpkg/installed/x64-windows/lib/libmariadb.lib -DCMAKE_TOOLCHAIN_FILE=F:\gitP\Microsoft\vcpkg\scripts\buildsystems\vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows ..
  11. msbuild /m /p:Platform=x64 /p:Configuration=Release /p:PlatformToolset=v143 tfs.sln /t:Rebuild (or msbuild /m /p:Platform=x64 /p:Configuration=Release /p:PlatformToolset=v143 vc17/theforgottenserver.vcxproj /t:Rebuild)

Expected behaviour

Build sucessfully.

Actual behaviour

F:\gitP\otland\forgottenserver\src\tools.h(77,25): error C2278: 'constant': unexpected token. Format is '__has_cpp_attribute( identifier )' [F:\gitP\otland\forgottenserver\build_amd64\src\tfslib.vcxproj]

Environment

Windows Server 2022

Reproduction environment

VS2022

build log: build.log

Codinablack commented 7 months ago

This is not a bug.

image

C++23 isn't even fully supported by even a single compiler yet!

The latest flag would be using for the next draft (C++26) as you can see in the uploaded screenshot from this link : https://learn.microsoft.com/en-us/cpp/build/reference/std-specify-language-standard-version?view=msvc-170

This error is due to enabling an unsupported target language, it is therefore not a bug in this software. We can close.

@Zhaojun-Liu I recommend just using the c++20 that is now the standard for most c++ projects.

Zhaojun-Liu commented 7 months ago

This is not a bug.

image

C++23 isn't even fully supported by even a single compiler yet!

The latest flag would be using for the next draft (C++26) as you can see in the uploaded screenshot from this link : https://learn.microsoft.com/en-us/cpp/build/reference/std-specify-language-standard-version?view=msvc-170

This error is due to enabling an unsupported target language, it is therefore not a bug in this software. We can close.

@Zhaojun-Liu I recommend just using the c++20 that is now the standard for most c++ projects.

Ok, got it. Thank you~