SWIG "multiply defined" error on C header file

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

SWIG "multiply defined" error on C header file

by Evan Klitzke-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi all,

I'm trying to write a Python binding, using SWIG, to CLD
(http://hail.wiki.kernel.org/index.php/CLD). I was hoping to start
with the "truly lazy" approach described on the SWIG tutorial, and
started with a trivial interface file like this:

%module cldc
%{
#define SWIG_FILE_WITH_INIT
#include "../include/cldc.h"
%}
%include "../include/cldc.h"

I then tried compiling this using swig, but get an error like so:

[evan@t500 py (master)]$ swig -python cldc.i
../include/cldc.h:33: Error: 'cldc_call_opts_u_get' is multiply
defined in the generated module.
../include/cldc.h:28: Error: Previous declaration of 'cldc_call_opts_u_get'

Everything I've found online about the meaning of this error is
discussing SWIG bindings to C++ code, where a method/function is
defined in multiple namespaces, which isn't the case here -- this is
vanilla C code. I think that SWIG is choking on the the header file
which is valid, but I'm not confident enough with my SWIG knowledge to
say for sure.

For reference, I'm using SWIG 1.3.40, and I've pastebinned the cldc.h
file at http://paste.pocoo.org/show/148964/ . The git repo for the
project (just clone git://git.kernel.org/pub/scm/daemon/cld/cld.git )
is pretty small if you want to test it out yourself.

Thanks!

--
Evan Klitzke <evan@...> :wq

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Swig-user mailing list
Swig-user@...
https://lists.sourceforge.net/lists/listinfo/swig-user

Re: SWIG "multiply defined" error on C header file

by Josh Cherry :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



On Thu, 5 Nov 2009, Evan Klitzke wrote:

> I then tried compiling this using swig, but get an error like so:
>
> [evan@t500 py (master)]$ swig -python cldc.i
> ../include/cldc.h:33: Error: 'cldc_call_opts_u_get' is multiply
> defined in the generated module.
> ../include/cldc.h:28: Error: Previous declaration of 'cldc_call_opts_u_get'
>
> Everything I've found online about the meaning of this error is
> discussing SWIG bindings to C++ code, where a method/function is
> defined in multiple namespaces, which isn't the case here -- this is
> vanilla C code. I think that SWIG is choking on the the header file
> which is valid, but I'm not confident enough with my SWIG knowledge to
> say for sure.
>
> For reference, I'm using SWIG 1.3.40, and I've pastebinned the cldc.h
> file at http://paste.pocoo.org/show/148964/ . The git repo for the
> project (just clone git://git.kernel.org/pub/scm/daemon/cld/cld.git )
> is pretty small if you want to test it out yourself.

It may have to do with the fact that you have a data member named "get".
SWIG would generate a low-level Python function
called cldc_call_opts_u_get for accessing cldc_call_opts.u, and this might
conflict internally with cldc_call_opts.u.  Just a wild guess.

Josh


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Swig-user mailing list
Swig-user@...
https://lists.sourceforge.net/lists/listinfo/swig-user

Re: SWIG "multiply defined" error on C header file

by Evan Klitzke-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Sat, Nov 7, 2009 at 11:24 AM, Josh Cherry <jcherry@...> wrote:

>
>
> On Thu, 5 Nov 2009, Evan Klitzke wrote:
>
>> I then tried compiling this using swig, but get an error like so:
>>
>> [evan@t500 py (master)]$ swig -python cldc.i
>> ../include/cldc.h:33: Error: 'cldc_call_opts_u_get' is multiply
>> defined in the generated module.
>> ../include/cldc.h:28: Error: Previous declaration of
>> 'cldc_call_opts_u_get'
>>
>> Everything I've found online about the meaning of this error is
>> discussing SWIG bindings to C++ code, where a method/function is
>> defined in multiple namespaces, which isn't the case here -- this is
>> vanilla C code. I think that SWIG is choking on the the header file
>> which is valid, but I'm not confident enough with my SWIG knowledge to
>> say for sure.
>>
>> For reference, I'm using SWIG 1.3.40, and I've pastebinned the cldc.h
>> file at http://paste.pocoo.org/show/148964/ . The git repo for the
>> project (just clone git://git.kernel.org/pub/scm/daemon/cld/cld.git )
>> is pretty small if you want to test it out yourself.
>
> It may have to do with the fact that you have a data member named "get".
> SWIG would generate a low-level Python function called cldc_call_opts_u_get
> for accessing cldc_call_opts.u, and this might conflict internally with
> cldc_call_opts.u.  Just a wild guess.

Thanks Josh, this was exactly the problem. I plan on reporting this to
the swig-developers list.
--
Evan Klitzke <evan@...> :wq

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Swig-user mailing list
Swig-user@...
https://lists.sourceforge.net/lists/listinfo/swig-user