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

Monks,

I have been trying to follow the Soldier example in Inline-C-Cookbook however I do not understand the purpose of the line

New(42, soldier, 1, Soldier);

Could someone explain to me what this line does?

Best regards,

Ty

Replies are listed 'Best First'.
Re: question on Inline::C-Cookbook
by BrowserUk (Patriarch) on Feb 19, 2014 at 19:13 UTC

    See also odd line in windows and especially Re^12: odd line in windows.


    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.
      especially Re^12: odd line in windows

      I've just replaced (in git) the old rendition with the one that BrowserUk linked to (written by ikegami).

      Nothing really wrong with the older version - works fine, and is quite comprehensible once you understand what newSVrv() does.
      But this amended version is more readily digestible ... and so it "gets the guernsey".

      Here's hoping that the "if it aint broke don't fix it" principle doesn't jump up and bite me ;-)

      Cheers,
      Rob

        If you haven't already you might want to update ikegami's use of New() to the newer Newx?().


        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.
Re: question on Inline::C-Cookbook
by Anonymous Monk on Feb 19, 2014 at 18:26 UTC
      Thank you so much. This answered my question.