From 0c2d0fea0fa882cc92ba40635ef09524deea4eea Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 9 Sep 2022 07:49:48 +0100 Subject: [PATCH] Move SwigValueWrapper to header section Recent change to SwigValueWrapper required the header. Included headers should be after the include of the language specific header files (which go into the earlier runtime section). Testcase required -Winit-list-lifetime warning suppression change for Perl which somehow lost the warning suppression when put into the %begin section. --- Examples/test-suite/cpp11_initializer_list.i | 2 +- Lib/swig.swg | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Examples/test-suite/cpp11_initializer_list.i b/Examples/test-suite/cpp11_initializer_list.i index b309576c1..c1646248c 100644 --- a/Examples/test-suite/cpp11_initializer_list.i +++ b/Examples/test-suite/cpp11_initializer_list.i @@ -10,7 +10,7 @@ $1 = {"Ab", "Fab"}; %} -%begin %{ +%runtime %{ #if __GNUC__ >= 9 /* warning: ‘new’ of initializer_list does not extend the lifetime of the underlying array [-Winit-list-lifetime] */ /* incorrect warning for C::C(std::initializer_list) */ diff --git a/Lib/swig.swg b/Lib/swig.swg index 9148c9153..6cac0e377 100644 --- a/Lib/swig.swg +++ b/Lib/swig.swg @@ -665,7 +665,9 @@ namespace std { */ #ifdef __cplusplus -%insert("runtime") %{ +// Placed in the header section to ensure the language specific header files are +// the first included headers and not +%insert("header") %{ #ifdef __cplusplus #include /* SwigValueWrapper is described in swig.swg */ @@ -688,7 +690,7 @@ public: operator T&() const { return *pointer.ptr; } #endif T *operator&() const { return pointer.ptr; } -};%} +}; /* * SwigValueInit() is a generic initialisation solution as the following approach: @@ -699,13 +701,10 @@ public: * * unsigned int c_result = unsigned int(); */ -%insert("runtime") %{ template T SwigValueInit() { return T(); } -%} -%insert("runtime") %{ #if __cplusplus >=201103L # define SWIG_STD_MOVE(OBJ) std::move(OBJ) #else