SWIG interface file questions

Posted by morpheous on Stack Overflow See other posts from Stack Overflow or by morpheous
Published on 2010-05-30T10:02:44Z Indexed on 2010/05/30 10:12 UTC
Read the original article Hit count: 143

Filed under:
|
|

I am writing a C/C++ extension module for other languages and I am using SWIG to generate the bindings.

I have two questions

  1. Can I include more than 1 header file in the declaration part of the interface file e.g.:

    /* Declarations exposed to wrapper: */

    > %{
    > #define SWIG_FILE_WITH_INIT
    > #include "a.h"
    > #include "b.h"
    > #include "c.h" %}
    
  2. In all of the examples I have seen so far, after the header include declaration (as shown above), the functions declared in the header are then declared again in the interface file. Is this really necessary, as it means there are two copies of the function declarations that need to be maintained.

Note: I can appreciate that some functions/methods declaration may need to be 'decorated' with the 'newobject' declaration so these obviously need to be in the interface file, to avoid memory leaks - however, I would have though that it would be sufficient to include the headers and then ONLY the declarations of the functions/methods that need to be declared with 'newobject' - is this recommended way of doing things?

© Stack Overflow or respective owner

Related posts about c++

Related posts about c