http://www.perlmonks.org?node_id=11158886

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

First of all, i have to admit that i feel that i should know this already, but i just don't.

Is it possible to add external cpp/h files when using Inline::CPP? I only need XS bindings for the stuff i'm inlining, the rest only needs to be accesible through the inlined CPP code.

Here is the simplest example i could tink of.

test.pl
use Inline CPP; for(1..3) { print "Perfect random number: ", cast_die(), "\n"; } __END__ __CPP__ #include "xkcd.h" int cast_die() { int rolled = xkcd_dice_roll(); return rolled; }
xkcd.h
#ifndef XKCD_DICE #define XKCD_DICE // See https://xkcd.com/221/ for why this is absolutely perfect #define FAIRLY_GENERATED_RANDOM_NUMBER 4 int xkcd_dice_roll(); #endif
xkcd.cpp
#include "xkcd.h" int xkcd_dice_roll() { return FAIRLY_GENERATED_RANDOM_NUMBER; }

Is something like this even possible with Inline::CPP?

PerlMonks XP is useless? Not anymore: XPD - Do more with your PerlMonks XP