mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-22 05:05:11 +00:00
a90e2af88d
* Factor out pybind11/compat/wrap_include_python_h.h * Fixes to resolve tests_packaging failures. * Factor out pybind11/compat/pybind11_platform_abi_id.h * Add pybind11/compat/README.txt and a couple source code comments. * Minor changes to comments. * Factor out pybind11/compat/pybind11_conduit_v1.h * Add long comment to pybind11/compat/pybind11_conduit_v1.h * Add pybind11/compat/README.txt to wheels. * Add `-fno-exceptions` to compiler options for exo_planet_c_api * 1. Move `target_compile_options()` into loop over test targets, in case the `"exo_planet_c_api"` target does not exist. 2. Add `-fno-exceptions` option also for `NVHPC`. 3. Also check for `__cpp_exceptions` in exo_planet_c_api.cpp. * 1. Fix accident (forgot to undo temporary change). 2. Special-case __EMSCRIPTEN__ in exo_planet_c_api.cpp * Give up on compiling exo_planet_c_api.cpp with MSVC `/EHs-c-`: There was one trouble maker (all other jobs worked): Visual Studio 15 2017: ``` cl : Command line warning D9025: overriding '/EHc' with '/EHc-' [C:\projects\pybind11\tests\exo_planet_c_api.vcxproj] ... C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\xlocale(319): error C2220: warning treated as error - no 'object' file generated [C:\projects\pybind11\tests\exo_planet_c_api.vcxproj] C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\xlocale(319): warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc ``` * Move pybind11/compat to pybind11/conduit as suggested by @henryiii: https://github.com/pybind/pybind11/pull/5375#pullrequestreview-2329006001
73 lines
2.0 KiB
C
73 lines
2.0 KiB
C
#pragma once
|
|
|
|
// Copyright (c) 2024 The pybind Community.
|
|
|
|
// STRONG REQUIREMENT:
|
|
// This header is a wrapper around `#include <Python.h>`, therefore it
|
|
// MUST BE INCLUDED BEFORE ANY STANDARD HEADERS are included.
|
|
// See also:
|
|
// https://docs.python.org/3/c-api/intro.html#include-files
|
|
// Quoting from there:
|
|
// Note: Since Python may define some pre-processor definitions which affect
|
|
// the standard headers on some systems, you must include Python.h before
|
|
// any standard headers are included.
|
|
|
|
// To maximize reusability:
|
|
// DO NOT ADD CODE THAT REQUIRES C++ EXCEPTION HANDLING.
|
|
|
|
// Disable linking to pythonX_d.lib on Windows in debug mode.
|
|
#if defined(_MSC_VER) && defined(_DEBUG) && !defined(Py_DEBUG)
|
|
// Workaround for a VS 2022 issue.
|
|
// See https://github.com/pybind/pybind11/pull/3497 for full context.
|
|
// NOTE: This workaround knowingly violates the Python.h include order
|
|
// requirement (see above).
|
|
# include <yvals.h>
|
|
# if _MSVC_STL_VERSION >= 143
|
|
# include <crtdefs.h>
|
|
# endif
|
|
# define PYBIND11_DEBUG_MARKER
|
|
# undef _DEBUG
|
|
#endif
|
|
|
|
// Don't let Python.h #define (v)snprintf as macro because they are implemented
|
|
// properly in Visual Studio since 2015.
|
|
#if defined(_MSC_VER)
|
|
# define HAVE_SNPRINTF 1
|
|
#endif
|
|
|
|
#if defined(_MSC_VER)
|
|
# pragma warning(push)
|
|
# pragma warning(disable : 4505)
|
|
// C4505: 'PySlice_GetIndicesEx': unreferenced local function has been removed
|
|
#endif
|
|
|
|
#include <Python.h>
|
|
#include <frameobject.h>
|
|
#include <pythread.h>
|
|
|
|
#if defined(_MSC_VER)
|
|
# pragma warning(pop)
|
|
#endif
|
|
|
|
#if defined(PYBIND11_DEBUG_MARKER)
|
|
# define _DEBUG
|
|
# undef PYBIND11_DEBUG_MARKER
|
|
#endif
|
|
|
|
// Python #defines overrides on all sorts of core functions, which
|
|
// tends to wreak havok in C++ codebases that expect these to work
|
|
// like regular functions (potentially with several overloads).
|
|
#if defined(isalnum)
|
|
# undef isalnum
|
|
# undef isalpha
|
|
# undef islower
|
|
# undef isspace
|
|
# undef isupper
|
|
# undef tolower
|
|
# undef toupper
|
|
#endif
|
|
|
|
#if defined(copysign)
|
|
# undef copysign
|
|
#endif
|