title: Swig error with Nested enums in C++
body: <p>I have a class similar to the following. It has a nested enum OptionTag.</p>
  
  <pre><code>class MediaPacket
  {
      public:
             struct RtcpAppName {
             char mName[RTCP_APPNAME_LENGTH];
             };
  
            enum OptionTag {
                           RESERVED  = 0,
                           PROFILE   = 1,
                           LATENCY   = 2,
                           PKTLOSS   = 3,
                           JITTER    = 4,
                           LEGACYMIX = 5,
                           LASTTAG   = 255
                       };
  
                      ....
                      ....
            list&lt;OptionTag&gt; GetOptions(unsigned int ssrc) const;
  };
  </code></pre>
  
  <p>For this I created a swig interface as follows</p>
  
  <pre><code>%module mediaopts_packet
  %include "stdint.i"
  
  //Redefining nested structure in swig
  struct RtcpAppName {
  char mName[RTCP_APPNAME_LENGTH];
  };
  
  
  %{
      #define SWIG_FILE_WITH_INIT
      #include "../include/mediaopts_packet.h"
  %}
  
  //nestedworkaround key for the nested struct
  %nestedworkaround CRtcpAppPacket::RtcpAppName;
  %{
  typedef CRtcpAppPacket::RtcpAppName RtcpAppName;
  %}
  
  //Some swig definitions that are not related to this problem
  //%include "carrays.i"
  //%array_class(uint8_t, buffer);
  
  //%include "typemaps.i"
  //%apply (unit8_t *STRING, int LENGTH) { (uint8_t *id, uint32_t len) };
  //%apply uint32_t &amp; OUTPUT { uint32_t &amp; xmitOpt };
  //%apply uint32_t &amp; OUTPUT { uint32_t &amp; rcvOpt };
  //%apply uint32_t &amp; OUTPUT { uint32_t &amp; optValue };
  
  %include "std_list.i"
  
  namespace std
  {
      %template(ListUint32) list&lt;uint32_t&gt;;
      %template(ListOptionTag) list&lt;CRtcpAppMediaoptsPacket::OptionTag&gt;;
  }
  
  %include "../include/mediaopts_packet.h"
  </code></pre>
  
  <hr>
  
  <p>Using the code in python</p>
  
  <pre><code>Python 2.7.2+ (default, Oct  4 2011, 20:03:08)
  [GCC 4.6.1] on linux2
  Type "help", "copyright", "credits" or "license" for more information.
  &gt;&gt;&gt; import mediaopts_packet
  &gt;&gt;&gt;
  &gt;&gt;&gt; packet = mediaopts_packet.MediaPacket()
  &gt;&gt;&gt;
  &gt;&gt;&gt; packet.AddSSRC(0,1,1)
  &gt;&gt;&gt;
  &gt;&gt;&gt; packet.GetAllSSRC()
  (0,)
  &gt;&gt;&gt; ssrc_list = mediaopts_packet.ListUint32()
  &gt;&gt;&gt;
  &gt;&gt;&gt; ssrc_list = packet.GetAllSSRC()
  &gt;&gt;&gt;
  &gt;&gt;&gt; ssrc_list
  (0,)
  &gt;&gt;&gt; ssrc_list[0]
  0
  &gt;&gt;&gt; packet.AddOption(0, mediaopts_packet.MediaPacket.RESERVED, 0)
  0
  &gt;&gt;&gt; packet.GetOptions(0)
  Segmentation fault
  </code></pre>
  
  <p>After building when I use this in python I get a segmentation fault. I am not able to understand what I missed. Please help.</p>