From 848cb3f95ec6f5f77f8ee28773d197d7035a8454 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Thu, 28 Jul 2022 07:06:00 +1200 Subject: [PATCH] Document lack of separate ISO C tag namespace This is a long-standing limitation, but only seems to have been reported once back in 2004. Nobody's cared enough to address it in 18 years, but we can at least document it in the manual rather than only in a source code comment in Source/Swig/symbol.c. Addresses https://sourceforge.net/p/swig/bugs/429/ --- Doc/Manual/SWIG.html | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html index 8d8f7bd45..b7021c468 100644 --- a/Doc/Manual/SWIG.html +++ b/Doc/Manual/SWIG.html @@ -2528,6 +2528,45 @@ This section describes the behavior of SWIG when processing ISO C structures and handle C++ are described in the next section.

+

+ISO C has a separate tag name space in which the names of structures, +unions and enumerated types are put, which is separate from the +name space for ordinary identifiers (function names, object names, +typedef names, enumeration constants). For example, this is valid +ISO C because Foo the struct tag and Foo the function +name are in different name spaces: +

+ +
+struct Foo {
+  int bar;
+};
+
+int Foo(void) { return 42; }
+
+ +

+SWIG doesn't currently implement this separate tag name space and +for the above example you'll get: +

+ +
+foo.i:5: Warning 302: Identifier 'Foo' redefined (ignored),
+foo.i:1: Warning 302: previous definition of 'Foo'.
+
+ +

+In practice this rarely actually causes problems, particular because +SWIG has special handling for typedef so cases such as this +work: +

+ +
+typedef struct Foo {
+  int bar;
+} Foo;
+
+

If SWIG encounters the definition of a structure or union, it creates a set of accessor functions. Although SWIG does not need @@ -2539,8 +2578,7 @@ to an individual member. For example, the declaration :

 struct Vector {
   double x, y, z;
-}
-
+};