View on
MetaCPAN is shutting down
For details read Perl NOC. After June 25th this page will redirect to
David Mertens > C-TinyCompiler > C::TinyCompiler::Perl



Annotate this POD

View/Report Bugs


C::TinyCompiler::Perl - Enabling Perl's full C-API in your C::TinyCompiler context


 use C::TinyCompiler;
 # Declare the compiler context with the Perl bindings:
 my $context= C::TinyCompiler->new('::Perl');
 # Or add them afterwards:
 my $context = C::TinyCompiler->new;
 # Create a function that tells us how many arguments we sent:
 $context->code('Body') = q{
     void test_func(AV * inputs, AV * outputs) {
         printf("You sent %d arguments\n", av_len(inputs));
 # Compile and call:
 $context->call_function('test_func', 1, 2, 3);


This module provides access to the full Perl C API in your compiler context. This is a very blunt tool, but it is guaranteed to always reflect the API of whichever version of Perl you use to run your script. It is equivalent to including the following in your Head code section:

 #include "EXTERN.h"
 #include "perl.h"
 #include "XSUB.h"

where it determines the path to your Perl's include directory during your script's compile phase. On my machine, the resulting text of this pull-in is equivalent to approximately 8,000 or 10,000 lines of real code, depending on how you define real (as well as many blank lines), which is why I consider it to be quite a blunt tool.

(What follows is what I *hope* happens, though it is not yet the reality.) This weight is the motivation for the C::TinyCompiler::Perl::* sub-modules. They pull in and define only the exact code that you need.


This module may lead to some interesting error messages. Here's a reference.

Unable to locate Perl CORE directory!

This compile-time error will indicate that C::TinyCompiler::Perl was not able to find the CORE directory in your Perl libs. This is a big issue because the header files that C::TinyCompiler::Perl wants to include in your compiler context can only be found in this directory. If you run into this problem, it means you do not have your Perl header files stored in a customary place. If you don't know how to fix this, you should reach out to me or to the Perl community (i.e. PerlMonks) for help.

whatever comes after C::TinyCompiler::Perl

If you see anything with this text in it, you have encountered an error (probably a compile error) in code that you added to your compiler's Head section after you added the C::TinyCompiler::Perl package. Check any and all code that you added. Using "line_numbers" in C::TinyCompiler may help narrow-down the errant line in your code.


David Mertens, <dcmertens.perl at>


Please report any bugs or feature requests at the project's main github page:


You can find documentation for this module with the perldoc command.

    perldoc C::TinyCompiler::Perl

You can also look for information at:


Code copyright 2012 Northwestern University. Documentation copyright 2012-2013 David Mertens.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See for more information.

syntax highlighting: