in reply to Using Inline::C in a package

I have no experience with Inline::C, but the following line seems suspicious:
use Inline C;

I would say there is a :: missing on line 7.

Update.
It works for me if I change it to

use Inline 'C';

Note that using the fat comma (=>) automatically quotes the C. This problem only happens under strict.

لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Replies are listed 'Best First'.
Re^2: Using Inline::C in a package
by BrowserUk (Patriarch) on Sep 04, 2013 at 16:59 UTC
    I would say there is a :: missing on line 7.

    No. The OP is exactly correct. That is how Inline C is used. Though it is normal followd by some other arguments; Eg. This is my standard usage:

    #! perl -slw use strict; use Inline C => Config => BUILD_NOISY => 1; use Inline C => <<'END_C', NAME => 'rdtsc', CLEAN_AFTER_BUILD => 0; SV *rdtsc() { return newSVuv( (UV)__rdtsc() ); } ... END_C use Data::Dump qw[ pp ]; use GD; ...

    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      OK, I stand corrected. Is the repetition of the use line also demanded?
      لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

        Often yes. See my update above.


        With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.
      So does the C code go before the package declaration? I'm confused on where the perl methods go before or after the C code.
Re^2: Using Inline::C in a package
by davido (Cardinal) on Sep 04, 2013 at 18:16 UTC

    To clarify why it's "that way":

    You actually are using Inline, with the C plugin. So "C" is an argument passed to Inline similar to how a function name might be specified in an import list.

    The reason it's often seen "bare" is because it's quite common to do it this way:

    use Inline C => 'DATA'; # ... __DATA__ __C__ /* C code here */

    In which case the "C" is actually quoted by the fat comma (=>) operator.

    Multiple uses of Inline C =>... are common and ok; one is often used to specify configuration settings, while others are used to initiate inline code sequences either via a here-doc or the __DATA__ segment.


    Dave