mesonbuild/meson

MSVC: /Zc:__cplusplus not set when --backend=vs

Open

#14,469 建立於 2025年4月10日

在 GitHub 查看
 (2 留言) (0 反應) (0 負責人)Python (4,978 star) (1,465 fork)batch import
backend:visualstudiobuggood first issue

描述

Describe the bug When configuring with MSVC, /Zc:__cplusplus is not set when using --backend=vs, but it is set when using --backend=ninja.

To Reproduce Please include your meson.build files, preferably as a minimal toy example showing the issue. You may need to create simple source code files (don't include private/proprietary code).

meson.build:

project('zccplusplus', 'cpp', meson_version: '>= 1.0',
    default_options:['cpp_std=vc++14', 'buildtype=debug', 'b_vscrt=static_from_buildtype', 'b_ndebug=if-release'])

static_library('zccplusplus', 'zctest.cpp')

zctest.cpp:

#if __cplusplus == 199711L
#error Zc:__cplusplus flag not set
#endif

To reproduce: meson setup --backend=vs vbuild meson compile -C vbuild

The error is not shown if --backend=ninja is used instead.

Expected behavior /Zc:__cplusplus should be consistently set for every back-end when configuring with MSVC.

system parameters

  • Is this a cross build or just a plain native build (for the same computer)?

Native

  • what operating system (e.g. MacOS Catalina, Windows 10, CentOS 8.0, Ubuntu 18.04, etc.)

Windows 11, with MSVC 17.13.6

  • what Python version are you using e.g. 3.8.0

The one bundled with the meson.msi installer.

  • what meson --version

1.7.1

  • what ninja --version if it's a Ninja build

1.12.1 (but it's the --backend=vs that is broken)

Not urgent, can be easily worked around by adding add_project_arguments('/Zc:__cplusplus', language: 'cpp') (because ninja isn't hurt by the redundant setting).

貢獻者指南