SWIG vs C++ namespaces

View: New views
2 Messages — Rating Filter:   Alert me  

SWIG vs C++ namespaces

by Dale Wilson-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi SWIG experts,

I've run into a problem using SWIG Version 1.3.35 to wrap some C++ code
for use by C#.  I've created a simple test that demonstrates the problem.

My C++ header file (Abc.h) contains:

  #ifndef ABC_H
  #define ABC_H
  #pragma warning (disable:4290) // VC: don't mutter about throw
specification
  namespace one
  {
    class Unique
    {
      Unique();
      ~Unique();
      void test()const;
    };
  }

  namespace two
  {
    class Unique
    {
      Unique();
      ~Unique();
      void test()const;
    };
  }
  #endif // ABC_H

and the AbcAdapter.swg file contains:
  %module AbcAdapter
  %{
  // Generated from AbcAdapter.swg
  #include "stdafx.h"
  #include "Abc.h"
  %}
  %include <stl.i>
  %include <std_common.i>
  %include "Abc.h"


When I run the command:

swig.exe -c++ -csharp -Fmicrosoft  AbcAdapter.swg

It says:

Abc.h(19): Error: 'Unique' is multiply defined in the generated module.
Abc.h(9): Error: Previous declaration of 'Unique'
Project : error PRJ0019: A tool returned an error code from "Creating
CSharp wrapper"
--------------------
So how can I convince SWIG to pay attention to the namespace when
checking for duplicate class declarations?

Thanks,

Dale



-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Swig-user mailing list
Swig-user@...
https://lists.sourceforge.net/lists/listinfo/swig-user

Re: SWIG vs C++ namespaces

by zhiyang jiang :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



2008/6/10 Dale Wilson <wilsond@...>:
Hi SWIG experts,

I've run into a problem using SWIG Version 1.3.35 to wrap some C++ code
for use by C#.  I've created a simple test that demonstrates the problem.

My C++ header file (Abc.h) contains:

 #ifndef ABC_H
 #define ABC_H
 #pragma warning (disable:4290) // VC: don't mutter about throw
specification
 namespace one
 {
   class Unique
   {
     Unique();
     ~Unique();
     void test()const;
   };
 }

 namespace two
 {
   class Unique
   {
     Unique();
     ~Unique();
     void test()const;
   };
 }
 #endif // ABC_H

and the AbcAdapter.swg file contains:
 %module AbcAdapter
 %{
 // Generated from AbcAdapter.swg
 #include "stdafx.h"
 #include "Abc.h"
 %}
 %include <stl.i>
 %include <std_common.i>
 %include "Abc.h"


When I run the command:

swig.exe -c++ -csharp -Fmicrosoft  AbcAdapter.swg

It says:

Abc.h(19): Error: 'Unique' is multiply defined in the generated module.
Abc.h(9): Error: Previous declaration of 'Unique'
Project : error PRJ0019: A tool returned an error code from "Creating
CSharp wrapper"
--------------------
So how can I convince SWIG to pay attention to the namespace when
checking for duplicate class declarations?

Thanks,

Dale



-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Swig-user mailing list
Swig-user@...
https://lists.sourceforge.net/lists/listinfo/swig-user

see this url

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Swig-user mailing list
Swig-user@...
https://lists.sourceforge.net/lists/listinfo/swig-user
LightInTheBox - Buy quality products at wholesale price