From 561a1d843d5877ec06265a6dbc96eefef5d0a945 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Mon, 20 Sep 2021 15:04:51 +1200 Subject: [PATCH] Fix ODR violations Detected by compiling with GCC flags `-flto -Wodr`. --- Source/Modules/overload.cxx | 2 ++ Source/Modules/python.cxx | 3 ++- Source/Modules/r.cxx | 3 ++- Source/Modules/ruby.cxx | 2 ++ 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Source/Modules/overload.cxx b/Source/Modules/overload.cxx index 512c5da39..8a4ce48f7 100644 --- a/Source/Modules/overload.cxx +++ b/Source/Modules/overload.cxx @@ -21,6 +21,7 @@ String *argv_template_string; String *argc_template_string; +namespace { struct Overloaded { Node *n; /* Node */ int argc; /* Argument count */ @@ -28,6 +29,7 @@ struct Overloaded { int error; /* Ambiguity error */ bool implicitconv_function; /* For ordering implicitconv functions*/ }; +} static int fast_dispatch_mode = 0; static int cast_dispatch_mode = 0; diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 6bc7ef737..7d618635e 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -93,6 +93,7 @@ static int nortti = 0; static int relativeimport = 0; /* flags for the make_autodoc function */ +namespace { enum autodoc_t { AUTODOC_CLASS, AUTODOC_CTOR, @@ -103,7 +104,7 @@ enum autodoc_t { AUTODOC_CONST, AUTODOC_VAR }; - +} static const char *usage1 = "\ Python Options (available with -python)\n\ diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx index b3f109fc0..99db2275f 100644 --- a/Source/Modules/r.cxx +++ b/Source/Modules/r.cxx @@ -1301,13 +1301,14 @@ void R::addAccessor(String *memberName, Wrapper *wrapper, String *name, #define MAX_OVERLOAD 256 +namespace { struct Overloaded { Node *n; /* Node */ int argc; /* Argument count */ ParmList *parms; /* Parameters used for overload check */ int error; /* Ambiguity error */ }; - +} List * R::Swig_overload_rank(Node *n, bool script_lang_wrapping) { diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx index bb4d19d91..ec4a75dbd 100644 --- a/Source/Modules/ruby.cxx +++ b/Source/Modules/ruby.cxx @@ -116,6 +116,7 @@ public: /* flags for the make_autodoc function */ +namespace { enum autodoc_t { AUTODOC_CLASS, AUTODOC_CTOR, @@ -127,6 +128,7 @@ enum autodoc_t { AUTODOC_SETTER, AUTODOC_NONE }; +} static const char *usage = "\ Ruby Options (available with -ruby)\n\