title: How to ask SWIG to rename nested structures differently?
body: <p>Say I have an <code>example.h</code> file with following:</p>
  
  <pre><code>struct foo_bar {
    int x;
  };
  
  struct foo {
    struct {
      int y;
    } bar;
  };
  </code></pre>
  
  <p>and <code>example.i</code> with following:</p>
  
  <pre><code>%module example
  %{
  #include "example.h"
  %}
  %include "example.h"
  </code></pre>
  
  <p>Now, when I generate the SWIG wrapper, SWIG defines a new struct <code>foo_bar</code> to access the nested <code>bar</code> struct in <code>foo</code> (also <a href="http://www.swig.org/Doc3.0/SWIGDocumentation.html#SWIG_nested_structs" rel="nofollow">mentioned in the documentation</a>). However this is causing <code>foo_bar</code> struct to be duplicated and it is failing the compilation.</p>
  
  <p>So, how can I ask SWIG to use <code>foo2</code> when SWIG creates custom structs to access nested structs of <code>foo</code>, so that all nested structs for <code>foo</code> are created like <code>foo2_bar</code>? I tried <code>%rename</code> but it only renames the wrapper functions, not the custom structs created by SWIG to access nested structs.</p>