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

Hello Monks, I'm seeking to be at peace with Inline::CPP. This is my test code:

#!/usr/bin/perl use strict; use warnings; use Inline 'info', 'force', 'clean'; use Inline 'CPP'; print "9 + 16 = ", add(9, 16), "\n"; print "9 - 16 = ", subtract(9, 16), "\n"; __END__ __CPP__ random junk; int add(int x, int y) { return x + y; } int subtract(int x, int y) { return x - y; }

You'll note the glaring random junk that should cause gcc to error, but it doesnt, it compiles fine, and then perl complains that &main::add is undefined. Here is the output:

$ ./testInline.pl <-----------------------Information Section--------------------------- +--------> Information about the processing of your Inline CPP code: Your source code needs to be compiled. I'll use this build directory: /home/andy/projects/rigel/libs/_Inline/build/testInline_pl_6b67 and I'll install the executable as: /home/andy/projects/rigel/libs/_Inline/lib/auto/testInline_pl_6b67/tes +tInline_pl_6b67.so <-----------------------End of Information Section-------------------- +--------> Use of uninitialized value in join or string at /usr/local/share/perl5 +/Inline/C.pm line 603. Undefined subroutine &main::add called at ./testInline.pl line 7.

I'm using Slackware64 14.2+current, perl 5.28, packages installed via cpanm. If I test with Inline::C is works fine, but CPP doesn't. I'm lost, and cannot seem to find my way.

Thanks for your time.

Replies are listed 'Best First'.
Re: Inline::CPP code ignored
by davido (Cardinal) on Sep 16, 2018 at 15:25 UTC

    I believe the issue is that 'info' and 'print_info' are not recognized as valid config options for Inline::CPP. When I remove that specific option, the compilation occurs as it should. This is probably a bug.

    Any option not handled directly by Inline::CPP's code is supposed to propagate back to Inline::C. However, it does appear the info option works correctly with Inline::C. I suggest reporting this as an issue in the module's repo and either I or someone else with some time who follows the repo may be able to dig into it at some point.

    This is an annoying bug, given the fact that the Inline::CPP module DOES have an info handler that apparently isn't getting called. After some initial investigation I'm all the more interested. I'll try to take a look sometime this week.


    Dave

      I assume you mean the github repo, which I've done. Thanks! -Andy
Re: Inline::CPP code ignored
by jaandy (Acolyte) on Sep 16, 2018 at 15:22 UTC
    I think I found it, the problem is this line:
    use Inline 'info', 'force', 'clean';
    Everything works fine without it.

      Yes, that is the offending line in YOUR code, but only because it's tickling a bug in Inline::CPP that apparently has gone undetected for a long time. In particular 'info' isn't being handled correctly. 'force' and 'clean' are ok, so if you just remove 'info' from that line, everything else proceeds as it should.


      Dave

Re: Inline::CPP code ignored
by davido (Cardinal) on Sep 19, 2018 at 04:50 UTC

    FYI: This was fixed today and released to CPAN as version 0.75. For details you can refer to the issue in the module's Github repo.


    Dave