The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

C::Blocks::PerlAPI - C interface for interacting with Perl

SYNOPSIS

use strict;
use warnings;
use C::Blocks;
use C::Blocks::PerlAPI;

cshare {
    void say_hi() {
        PerlIO_stdoutf("hi!");
    }
}

DESCRIPTION

This C::Blocks module provides access to the Perl C library. It is roughly equivalent to including these lines at the top of your cblocks:

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

as well as linking to libperl. Of course, as a C::Blocks module, it also avoids the re-parsing necessary if you were to include those at the top of each of your cblocks.

The Perl C library is vast, and a tutorial for it may be useful at some point. Until that time, I will simply refer you to perlapi and perlguts.