Skip to content

/std:c++11 is not a valid MSVC compiler flag #881

@Simran-B

Description

@Simran-B

Bug Report

Build Problem

The root CMakeLists.txt tries to set C++11 as standard for pybind11:

if(MSVC)
    set(PYBIND11_CPP_STANDARD /std:c++11)

However, MSVC does not support this argument:

cl : Command line warning D9002: ignoring unknown option "/std:c++11"

https://docs.microsoft.com/en-us/cpp/build/reference/std-specify-language-standard-version?view=msvc-160

C++ 11 support in Visual Studio should be turned on by default. [source]

[...] msvc (and clang) [are] missing a dedicated c++11 std compiler switch (msvc automagically detects if code is using C++11 or C++03 etc.) [source]

Beware: /std:c11 sets C11 as standard, not C++11!

To Reproduce

  1. Operating System: Windows 10
  2. Python version: 2.7.18
  3. Example snippet that demonstrates the issue - if it's a build issue:
    cmake .. -G "Visual Studio 16 2019"
    cmake --build . --config Release
    
  4. OpenTimelineIO release version or commit hash: 22945fd
  5. Compiler information:
    Microsoft (R) C/C++-Optimierungscompiler Version 19.28.29333 für x64

Expected Behavior

There seem to be two options:

  1. Not set this option at all for MSVC
  2. Use target_compile_features(pybind11 PRIVATE cxx_std_11) (source) to let CMake handle it automatically

Logs

Microsoft (R)-Build-Engine, Version 16.8.1+bd2ea1e3c für .NET Framework
Copyright (C) Microsoft Corporation. Alle Rechte vorbehalten.

  Checking Build System
  Auto build dll exports
  opentime.vcxproj -> C:\Daten\Olive\Deps\OpenTimelineIO\build6\src\opentime\Release\opentime.dll
  Auto build dll exports
  opentimelineio.vcxproj -> C:\Daten\Olive\Deps\OpenTimelineIO\build6\src\opentimelineio\Release\opentimelineio.dll
cl : befehlszeile warning D9002: Unbekannte Option "/std:c++11" wird ignoriert. [C:\Daten\Olive\Deps\OpenTimelineIO\bui
ld6\src\py-opentimelineio\opentime-bindings\_opentime.vcxproj]
cl : befehlszeile warning D9002: Unbekannte Option "/std:c++11" wird ignoriert. [C:\Daten\Olive\Deps\OpenTimelineIO\bui
ld6\src\py-opentimelineio\opentime-bindings\_opentime.vcxproj]
  opentime_bindings.cpp
cl : befehlszeile warning D9002: Unbekannte Option "/std:c++11" wird ignoriert. [C:\Daten\Olive\Deps\OpenTimelineIO\bui
ld6\src\py-opentimelineio\opentime-bindings\_opentime.vcxproj]
  opentime_rationalTime.cpp
cl : befehlszeile warning D9002: Unbekannte Option "/std:c++11" wird ignoriert. [C:\Daten\Olive\Deps\OpenTimelineIO\bui
ld6\src\py-opentimelineio\opentime-bindings\_opentime.vcxproj]
  opentime_timeRange.cpp
cl : befehlszeile warning D9002: Unbekannte Option "/std:c++11" wird ignoriert. [C:\Daten\Olive\Deps\OpenTimelineIO\bui
ld6\src\py-opentimelineio\opentime-bindings\_opentime.vcxproj]
  opentime_timeTransform.cpp

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions