Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

SWIG or Inline::CPP

by Anonymous Monk
on Dec 05, 2005 at 12:29 UTC ( [id://514101]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hallo monks,
i am in dilemma whether to use inline or swig for my application. kindly let me know as to on what basis you can choose between these 2 and what each one has to offer. Any suggestions would be highly appreciated.
Regards
AB

Replies are listed 'Best First'.
Re: SWIG or Inline::CPP
by jesuashok (Curate) on Dec 05, 2005 at 15:18 UTC
    Hi

    Inline::CPP lets you write Perl subroutines and classes in C++. You don't have to learn XS or SWIG, you can just put code right "inline" in your source.

    use Inline CPP => <<'END'; class JAxH { public: JAxH(char *x); SV* data(); private: SV *dat; }; JAxH::JAxH(char *x) { dat = newSVpvf("Just Another %s Hacker", x); +} SV* JAxH::data() { return dat; } END print JAxH->new('Inline')->data(), "\n"; When run, this complete program prints: Just Another Inline Hacker.

    "Keep pouring your ideas"
      Hi,
      thanks for your suggestion. But is it necessary that the function declaration and definition should be enclosed within "END" blocks? I mean if the declaration is in .h and definition in .cpp do i have to create a separate file merging these two?
      rgds
      AB
        Hi, This is just what I want to ask: "if the declaration is in .h and definition in .cpp do i have to create a separate file merging these two in a perl file?? " Thanks Kelvin

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (2)
As of 2024-04-20 04:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found