Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^3: With Inline::C, how to link to external library? (XS)

by syphilis (Archbishop)
on Aug 09, 2016 at 10:30 UTC ( [id://1169396]=note: print w/replies, xml ) Need Help??


in reply to Re^2: With Inline::C, how to link to external library? (XS)
in thread With Inline::C, how to link to external library?

I can reproduce this exact behaviour with this simple script, by trying to link to a non-existent library

I can reproduce the problem with an even simpler script:
use Inline C => 'END'; say(); __END__ __C__ void say() { printf("6\n"); }
The first line of that code is wrong. The corrected version of that script is:
use Inline C; say(); __END__ __C__ void say() { printf("6\n"); }
Update: An alternative way of writing out the script would be:
say(); use Inline C => <<'END'; void say() { printf("6\n"); } END
I think that might have led to your confusion.

Cheers,
Rob

Replies are listed 'Best First'.
Re^4: With Inline::C, how to link to external library? (XS)
by stevieb (Canon) on Aug 09, 2016 at 13:20 UTC

    Yep, for the love of all things good... after all of my testing, I made the one mistake I rarely make; I made two changes at once instead of one at a time then testing.

    Although hacking the .h file seemed to work, it was at that time I also changed from using END to DATA. After further testing and reverting the changed file, it works just dandy.

    Thanks all for the feedback.

Re^4: With Inline::C, how to link to external library? (XS)
by Anonymous Monk on Aug 09, 2016 at 15:16 UTC

    A small clarification as to what happens here: The string 'END' and the __C__ section are combined to produce the C unit (C source code). After preprocessing, C compiler will see it as

    END void boot_duh(PerlInterpreter* my_perl __attribute__((unused)), CV* cv + __attribute__((unused))); void boot_duh(PerlInterpreter* my_perl __attribute__((unused)), CV* cv + __attribute__((unused)))
    Resulting bogus code trips up the compiler.

    Now the question is, why such a feature? Is it used a lot? Shouldn't there be a warning when source string and section are both present? Hm.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2024-04-18 05:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found