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/
This commit is contained in:
parent
346ede21c3
commit
848cb3f95e
1 changed files with 40 additions and 2 deletions
|
|
@ -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.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
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 <tt>Foo</tt> the struct tag and <tt>Foo</tt> the function
|
||||
name are in different name spaces:
|
||||
</p>
|
||||
|
||||
<div class="code"><pre>
|
||||
struct Foo {
|
||||
int bar;
|
||||
};
|
||||
|
||||
int Foo(void) { return 42; }
|
||||
</pre></div>
|
||||
|
||||
<p>
|
||||
SWIG doesn't currently implement this separate tag name space and
|
||||
for the above example you'll get:
|
||||
</p>
|
||||
|
||||
<div class="code"><pre>
|
||||
foo.i:5: Warning 302: Identifier 'Foo' redefined (ignored),
|
||||
foo.i:1: Warning 302: previous definition of 'Foo'.
|
||||
</pre></div>
|
||||
|
||||
<p>
|
||||
In practice this rarely actually causes problems, particular because
|
||||
SWIG has special handling for <tt>typedef</tt> so cases such as this
|
||||
work:
|
||||
</p>
|
||||
|
||||
<div class="code"><pre>
|
||||
typedef struct Foo {
|
||||
int bar;
|
||||
} Foo;
|
||||
</pre></div>
|
||||
|
||||
<p>
|
||||
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 :</p>
|
|||
<div class="code"><pre>
|
||||
struct Vector {
|
||||
double x, y, z;
|
||||
}
|
||||
|
||||
};
|
||||
</pre></div>
|
||||
|
||||
<p>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue