Writing Extension Functions
When you start writing the C/C++ functions that you want to be able to access from within Perl, you need to use the XS() macro:
XS( FunctionName )
The XS() macro declares the function as a Perl function. The parameter passed in will be the function name that will be mapped in the bootstrap function (see the section “The Bootstrap Function” later in this chapter).
Really, this is quite easy to do. Whenever you are creating a function that will be called directly from a Perl script, you just declare the function using the XS() macro. This will guarantee that the function can communicate with Perl.
After you have declared your function, you need to set up the Perl variables that are needed by many of Perl’s macros. ...
Get Win32 Perl Programming: The Standard Extensions, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.