Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^2: SWIG and conflicting definitions

by jdv (Sexton)
on Jan 07, 2016 at 19:17 UTC ( [id://1152236]=note: print w/replies, xml ) Need Help??


in reply to Re: SWIG and conflicting definitions
in thread SWIG and conflicting definitions

Thanks for the reply. This is all black magic to me (plus I think some newlines got lost in the code in your first paragraph) so I'm not sure if I got it right. Here is what I tried around the section you suggested:

#include "EXTERN.h" #include "perl.h" #define CV __perl_CV #include "XSUB.h" #undef XSPROTO #define XSPROTO(name) void name(pTHX_ __perl_CV* cv) #undef CV

That's just copying what you wrote and guessing at the newlines, so I'm not sure if the syntax is correct. If I try to compile this, the STDERR is down to ~ 1500 lines with a lot of messages like this:

pwiz_swigbindings_wrap.cxx:748:39: error: ‘__perl_CV’ has not been dec +lared #define XSPROTO(name) void name(pTHX_ __perl_CV* cv)

Replies are listed 'Best First'.
Re^3: SWIG and conflicting definitions
by hexcoder (Curate) on Jan 08, 2016 at 11:16 UTC
    My error, sorry. I should have said to put the line

    #define CV __perl_CV

    before this one

    #include "perl.h"

    otherwise it looks ok.

    Update: some explanations added

    What I intend to do, is this:

    1. for the processing of perl.h, XSUB.h and the included header files therein, substitute the offending identifier CV by __perl_CV. This is done by the preprocessor directive #define CV __perl_CV
    2. Afterwards redeclare the macro XSPROTO, which was using CV also. Unfortunately the above substitution affects only C code, but not subsequent preprocessor directives, so we need to adjust this macro definition.
      This is done by first deleting the old macro definition (#undef XSPROTO), and then by defining it again, but this time with __perl_CV instead of CV.
    3. Finally delete the substitution for identifier CV (#undef CV, so that the following code can use it exclusively.
    4. This in total should remove the conflict between the two different definitions of CV by using __perl_CV for the first one instead.

    If you are curious, you can look at the difference of the preprocessed outputs with and without the modification (gcc -E -dDfile should produce them).

      Thanks - that is progress. After making that change, STDERR is down to 21 lines. This is the full output:

      Here is the context refered to in the first line:

      I really appreciate the help so far. I'd love to get this working but troubleshooting at this level is beyond me.

        You could use

        #undef XSPROTO #define XSPROTO(name) void name(pTHX_ struct cv* cv)
        This should be compatible with the typedef. An incomplete type declaration
        struct cv;
        can't hurt either, though that shouldn't be necessary. Try this without that sneaky #define CV ...

        However, your boot_pwiz_swigbindings takes two arguments, whereas SWIG_init is expected to take one. Something needs a fix there as well.

        As suggested by Anonymous Monk you should modify the declarations. Substitute CV by struct cv in lines 1552, 1554 and 1557.

        But (as remarked by Anonymous Monk) another problem will show up then with the different prototypes of
        void boot_pwiz_swigbindings(PerlInterpreter*, int*) in line 1531 and
        SWIGEXPORT void boot_pwiz_swigbindings (pTHXo_ struct cv* cv) from line 1554.

        The type of the second parameter int * is incompatible to struct cv*. (The number of parameters seems to be right). It looks like SWIG did not generate this correctly with the supplied template. Maybe the template needs to be updated (line 1531 looks wrong). Anyhow, without access to the complete template and generated file it is quite difficult to guess how this could be rectified.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1152236]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2024-03-29 02:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found