in reply to Using Inline::C in a package

use Inline C;

... the "C" here is a bareword, so strict 'subs' doesn't like it. You could drop use strict, or you could quote "C" in single or double quotes...

use Inline 'C';

... or use the magic quoting power of the fat comma...

use Inline C => ();

Also, I'm pretty sure you want __DATA__ instead of __END__. __END__ behaves the same as __DATA__ in scripts, but not in modules.

Personally I don't like the __DATA__ loading bit of Inline::C; I just use:

use Inline C => q{ /* my C code goes here */ };

(or heredocs).

PS: a very simple module using Inline::C is Devel::PL_origargv - take a peek at the source code and let me know if you have any questions about it.

use Moops; class Cow :rw { has name => (default => 'Ermintrude') }; say Cow->new->name

Replies are listed 'Best First'.
Re^2: Using Inline::C in a package
by rem45acp (Novice) on Sep 04, 2013 at 17:18 UTC
    Based on all the responses, this is what I have so far. It gets past the build stage, but it complains about no __DATA__ section, and also cannot find the openDevice() function
    package PIC::DevaSysI2CIO; use strict; use Inline C => Config => LIBS => "-LE:/drivers/usb/devasys_i2cio -lusbi2cio", INC => "-IE:/drivers/usb/devasys_i2cio", BUILD_NOISY => 1; use Inline C => q { #include <windows.h> #include "Usbi2cio.h" HANDLE openDevice() { HANDLE h = INVALID_HANDLE_VALUE; h = DAPI_OpenDeviceInstance("UsbI2cio", 0); return h; } }; sub new { my ($class_name) = @_; my ($self) = {}; bless($self, $class_name); return $self; } sub open_device { my $h = openDevice(); } 1;