I'm trying to export C constants from a system header using ExtUtils::Constant.
As per the doc, I have in Makefile.PL:
ExtUtils::Constant::WriteConstants (
NAME => 'Foo::Bar',
NAMES => [ qw(EPOLLIN EPOLLOUT) ]
);
Then in Bar.xs:
#include "const-c.inc"
#include <sys/epoll.h> // hail mary...
MODULE = Foo::Bar PACKAGE = Foo::Bar
INCLUDE: const-xs.inc
However, when I run a test with:
is(Foo::Bar::EPOLLOUT, 4);
I get:
t/bar.t Bareword "Foo::Bar::EPOLLOUT" not allowed while "strict subs" in use
This would not be the case if EPOLLOUT existed as a constant; i.e. it's an invalid identifier.
How is this supposed to be done? I am not at all surprised this fails to set EPOLLOUT to the correct value -- the doc also says ExtUtils::Constant "doesn't contain the routines to scan header files to extract these constants" -- but while the .xs
code generated is over my head, I am a bit surprised that Foo::Bar::EPOLLOUT is not recognized as an identifier with an undef value, and the fact that it isn't leaves me confused as to what to try next.
I would contemplate the source of another perl module that uses ExtUtils::Constant, but the only one I can think of that exports system defines is POSIX, which is core (if anyone else knows of one please leave a comment).
24 hours later: Now cross-posted at Perl Monks.