@@ -77,6 +77,12 @@ IncludeCategories:
- Regex: '<Q([A-Za-z0-9\-_])+>'
CaseSensitive: true
Priority: 9
+ # Python.h hence pybind11 headers must be included first
+ # https://docs.python.org/3/c-api/intro.html#include-files
+ - Regex: '<pybind11/.*>'
+ Priority: -9
+ - Regex: '"py_.*"'
+ Priority: -8
# Headers in <> with an extension. (+system libraries)
- Regex: '<([A-Za-z0-9\-_])+\.h>'
Priority: 2
@@ -4,6 +4,7 @@
*/
#include "py_camera_manager.h"
+#include "py_main.h"
#include <errno.h>
#include <memory>
@@ -12,8 +13,6 @@
#include <unistd.h>
#include <vector>
-#include "py_main.h"
-
namespace py = pybind11;
using namespace libcamera;
@@ -5,12 +5,12 @@
#pragma once
+#include <pybind11/pybind11.h>
+
#include <libcamera/base/mutex.h>
#include <libcamera/libcamera.h>
-#include <pybind11/pybind11.h>
-
using namespace libcamera;
class PyCameraManager
@@ -5,15 +5,15 @@
* Python bindings - Color Space classes
*/
-#include <libcamera/color_space.h>
-#include <libcamera/libcamera.h>
-
#include <pybind11/operators.h>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include "py_main.h"
+#include <libcamera/color_space.h>
+#include <libcamera/libcamera.h>
+
namespace py = pybind11;
using namespace libcamera;
@@ -7,12 +7,12 @@
* This file is auto-generated. Do not edit.
*/
-#include <libcamera/{{header}}>
-
#include <pybind11/pybind11.h>
#include "py_main.h"
+#include <libcamera/{{header}}>
+
namespace py = pybind11;
class Py{{mode|capitalize}}
@@ -5,12 +5,12 @@
* Python bindings - Enumerations
*/
-#include <libcamera/libcamera.h>
-
#include <pybind11/pybind11.h>
#include "py_main.h"
+#include <libcamera/libcamera.h>
+
namespace py = pybind11;
using namespace libcamera;
@@ -7,12 +7,12 @@
* This file is auto-generated. Do not edit.
*/
-#include <libcamera/formats.h>
-
#include <pybind11/pybind11.h>
#include "py_main.h"
+#include <libcamera/formats.h>
+
namespace py = pybind11;
class PyFormats
@@ -5,17 +5,17 @@
* Python bindings - Geometry classes
*/
-#include <array>
-
-#include <libcamera/geometry.h>
-#include <libcamera/libcamera.h>
-
#include <pybind11/operators.h>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include "py_main.h"
+#include <array>
+
+#include <libcamera/geometry.h>
+#include <libcamera/libcamera.h>
+
namespace py = pybind11;
using namespace libcamera;
@@ -3,14 +3,14 @@
* Copyright (C) 2022, Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
*/
-#include "py_helpers.h"
-
-#include <libcamera/libcamera.h>
-
#include <pybind11/functional.h>
#include <pybind11/stl.h>
#include <pybind11/stl_bind.h>
+#include "py_helpers.h"
+
+#include <libcamera/libcamera.h>
+
namespace py = pybind11;
using namespace libcamera;
@@ -5,9 +5,9 @@
#pragma once
-#include <libcamera/libcamera.h>
-
#include <pybind11/pybind11.h>
+#include <libcamera/libcamera.h>
+
pybind11::object controlValueToPy(const libcamera::ControlValue &cv);
libcamera::ControlValue pyToControlValue(const pybind11::object &ob, libcamera::ControlType type);
@@ -5,6 +5,13 @@
* Python bindings
*/
+#include <pybind11/functional.h>
+#include <pybind11/pybind11.h>
+#include <pybind11/stl.h>
+#include <pybind11/stl_bind.h>
+
+#include "py_camera_manager.h"
+#include "py_helpers.h"
#include "py_main.h"
#include <limits>
@@ -17,14 +24,6 @@
#include <libcamera/libcamera.h>
-#include <pybind11/functional.h>
-#include <pybind11/pybind11.h>
-#include <pybind11/stl.h>
-#include <pybind11/stl_bind.h>
-
-#include "py_camera_manager.h"
-#include "py_helpers.h"
-
namespace py = pybind11;
using namespace libcamera;
@@ -5,10 +5,10 @@
#pragma once
-#include <libcamera/base/log.h>
-
#include <pybind11/pybind11.h>
+#include <libcamera/base/log.h>
+
namespace libcamera {
LOG_DECLARE_CATEGORY(Python)
@@ -5,15 +5,15 @@
* Python bindings - Transform class
*/
-#include <libcamera/transform.h>
-#include <libcamera/libcamera.h>
-
#include <pybind11/operators.h>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include "py_main.h"
+#include <libcamera/transform.h>
+#include <libcamera/libcamera.h>
+
namespace py = pybind11;
using namespace libcamera;
Python.h hence the pybind headers must be included first since pyconfig.h unconditionally overrides certain feature test macros[0]. This was mostly hidden by the fact that macro redefinitions with the same value do not trigger compiler warnings. However, glibc 43 has changed certain defaults[1], causing mismatches, leading to compiler warnings. So change the include order so that `<pybind11/...>` headers are included first and then the local `"py_..."` headers, and then everything else. Also adjust `.clang-format` as well. [0]: https://docs.python.org/3/c-api/intro.html#include-files [1]: https://sourceware.org/git/?p=glibc.git;a=commit;h=a5cc3018f31a125f019685b239c6e5a0bf1a272b Link: https://github.com/python/cpython/issues/61322 Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com> --- .clang-format | 6 ++++++ src/py/libcamera/py_camera_manager.cpp | 3 +-- src/py/libcamera/py_camera_manager.h | 4 ++-- src/py/libcamera/py_color_space.cpp | 6 +++--- src/py/libcamera/py_controls_generated.cpp.in | 4 ++-- src/py/libcamera/py_enums.cpp | 4 ++-- src/py/libcamera/py_formats_generated.cpp.in | 4 ++-- src/py/libcamera/py_geometry.cpp | 10 +++++----- src/py/libcamera/py_helpers.cpp | 8 ++++---- src/py/libcamera/py_helpers.h | 4 ++-- src/py/libcamera/py_main.cpp | 15 +++++++-------- src/py/libcamera/py_main.h | 4 ++-- src/py/libcamera/py_transform.cpp | 6 +++--- 13 files changed, 41 insertions(+), 37 deletions(-)