O'Reilly logo

Win32 Perl Programming: The Standard Extensions, Second Edition by Dave Roth

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required