Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-01-09 10:20:47

0001 // Copyright (c) 2016-2025 The Pybind Development Team.
0002 // All rights reserved. Use of this source code is governed by a
0003 // BSD-style license that can be found in the LICENSE file.
0004 
0005 #pragma once
0006 
0007 // PLEASE DO NOT ADD ANY INCLUDES HERE
0008 
0009 // Define some generic pybind11 helper macros for warning management.
0010 //
0011 // Note that compiler-specific push/pop pairs are baked into the
0012 // PYBIND11_NAMESPACE_BEGIN/PYBIND11_NAMESPACE_END pair of macros. Therefore manual
0013 // PYBIND11_WARNING_PUSH/PYBIND11_WARNING_POP are usually only needed in `#include` sections.
0014 //
0015 // If you find you need to suppress a warning, please try to make the suppression as local as
0016 // possible using these macros. Please also be sure to push/pop with the pybind11 macros. Please
0017 // only use compiler specifics if you need to check specific versions, e.g. Apple Clang vs. vanilla
0018 // Clang.
0019 #if defined(_MSC_VER)
0020 #    define PYBIND11_COMPILER_MSVC
0021 #    define PYBIND11_PRAGMA(...) __pragma(__VA_ARGS__)
0022 #    define PYBIND11_WARNING_PUSH PYBIND11_PRAGMA(warning(push))
0023 #    define PYBIND11_WARNING_POP PYBIND11_PRAGMA(warning(pop))
0024 #elif defined(__INTEL_COMPILER)
0025 #    define PYBIND11_COMPILER_INTEL
0026 #    define PYBIND11_PRAGMA(...) _Pragma(#__VA_ARGS__)
0027 #    define PYBIND11_WARNING_PUSH PYBIND11_PRAGMA(warning push)
0028 #    define PYBIND11_WARNING_POP PYBIND11_PRAGMA(warning pop)
0029 #elif defined(__clang__)
0030 #    define PYBIND11_COMPILER_CLANG
0031 #    define PYBIND11_PRAGMA(...) _Pragma(#__VA_ARGS__)
0032 #    define PYBIND11_WARNING_PUSH PYBIND11_PRAGMA(clang diagnostic push)
0033 #    define PYBIND11_WARNING_POP PYBIND11_PRAGMA(clang diagnostic pop)
0034 #elif defined(__GNUC__)
0035 #    define PYBIND11_COMPILER_GCC
0036 #    define PYBIND11_PRAGMA(...) _Pragma(#__VA_ARGS__)
0037 #    define PYBIND11_WARNING_PUSH PYBIND11_PRAGMA(GCC diagnostic push)
0038 #    define PYBIND11_WARNING_POP PYBIND11_PRAGMA(GCC diagnostic pop)
0039 #endif
0040 
0041 #ifdef PYBIND11_COMPILER_MSVC
0042 #    define PYBIND11_WARNING_DISABLE_MSVC(name) PYBIND11_PRAGMA(warning(disable : name))
0043 #else
0044 #    define PYBIND11_WARNING_DISABLE_MSVC(name)
0045 #endif
0046 
0047 #ifdef PYBIND11_COMPILER_CLANG
0048 #    define PYBIND11_WARNING_DISABLE_CLANG(name) PYBIND11_PRAGMA(clang diagnostic ignored name)
0049 #else
0050 #    define PYBIND11_WARNING_DISABLE_CLANG(name)
0051 #endif
0052 
0053 #ifdef PYBIND11_COMPILER_GCC
0054 #    define PYBIND11_WARNING_DISABLE_GCC(name) PYBIND11_PRAGMA(GCC diagnostic ignored name)
0055 #else
0056 #    define PYBIND11_WARNING_DISABLE_GCC(name)
0057 #endif
0058 
0059 #ifdef PYBIND11_COMPILER_INTEL
0060 #    define PYBIND11_WARNING_DISABLE_INTEL(name) PYBIND11_PRAGMA(warning disable name)
0061 #else
0062 #    define PYBIND11_WARNING_DISABLE_INTEL(name)
0063 #endif
0064 
0065 #define PYBIND11_NAMESPACE_BEGIN(name)                                                            \
0066     namespace name {                                                                              \
0067     PYBIND11_WARNING_PUSH
0068 
0069 #define PYBIND11_NAMESPACE_END(name)                                                              \
0070     PYBIND11_WARNING_POP                                                                          \
0071     }
0072 
0073 // Robust support for some features and loading modules compiled against different pybind versions
0074 // requires forcing hidden visibility on pybind code, so we enforce this by setting the attribute
0075 // on the main `pybind11` namespace.
0076 #if !defined(PYBIND11_NAMESPACE)
0077 #    if defined(__GNUG__) && !defined(_WIN32)
0078 #        define PYBIND11_NAMESPACE pybind11 __attribute__((visibility("hidden")))
0079 #    else
0080 #        define PYBIND11_NAMESPACE pybind11
0081 #    endif
0082 #endif