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

This was originally posted to Stack Overflow more than a day ago; if that's a problem I can delete it as it is likely destined to end up as tumbleweed anyway.

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).