Author palotasb-conti
Recipients matrixise, palotasb-conti, paul.moore, steve.dower, tim.golden, zach.ware
Date 2019-02-18.12:03:41
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1550491421.6.0.562853688184.issue36020@roundup.psfhosted.org>
In-reply-to
Content
I have the following internal, almost-minimal test case for this bug. It also relies on Boost Python, but that could be eliminated to produce a similar test case.

# CMakeLists.txt
cmake_minimum_required(VERSION 3.0)
project(python-boost-mcve)
set(Boost_USE_STATIC_LIBS ON)
find_package(Boost COMPONENTS python36 REQUIRED)
find_package(Python3 COMPONENTS Development REQUIRED)
add_library(python-boost-mcve)
target_link_libraries(python-boost-mcve PUBLIC Python3::Python Boost::python36)
target_sources(python-boost-mcve PUBLIC
    "${CMAKE_CURRENT_SOURCE_DIR}/python-boost-mcve.cpp")

// python-boost-mcve.cpp
// 1. This is a bug with MSVC Python
#if !defined(_MSC_VER) || _MSC_VER < 1900
#  error "The MCVE requires Visual Studio 14.0 or higher"
#endif
// 2. An MSVC system header is required to reproduce the error for some reason,
// perhaps it sets some macro. This needs to be BEFORE <boost/python.hpp>
#include <array>
// 3. Boost Python is required to include the system (MSVC) Python headers that
// define _snprintf as a macro under the circumstances
// #define HAVE_SNPRINTF // Define this macro as a workaround to fix the compile error
#include <boost/python.hpp>
// 4. Now we can observe that the following function won't compile
#include <cstdio>
void test() {
    char buf[2];
    std::snprintf(buf, 1, "x");
    // error C2039: '_snprintf': is not a member of 'std' [python-boost-mcve.vcxproj]
}
History
Date User Action Args
2019-02-18 12:03:41palotasb-contisetrecipients: + palotasb-conti, paul.moore, tim.golden, zach.ware, steve.dower, matrixise
2019-02-18 12:03:41palotasb-contisetmessageid: <1550491421.6.0.562853688184.issue36020@roundup.psfhosted.org>
2019-02-18 12:03:41palotasb-contilinkissue36020 messages
2019-02-18 12:03:41palotasb-conticreate