NAME

Module::Build::FFI - Build Perl extensions if C with FFI.

VERSION

version 0.08

SYNOPSIS

raw Build.PL:

use Module::Build::FFI 0.04;
Module::Build::FFI->new(
  module_name => 'Foo::Bar',
  ...
)->create_build_script;

Dist::Zilla:

[ModuleBuild]
mb_class      = Module::Build::FFI

[Prereqs / ConfigureRequires]
Module::Build::FFI = 0.03

Put your .c and .h files in ffi (ffi/example.c):

#include <ffi_util.h>
#include <stdio.h>

FFI_UTIL_EXPORT void print_hello(void)
{
  printf("hello world\n");
}

Attach it in your main module:

package Foo::Bar;

use FFI::Raw;
use FFI::Util qw( locate_module_share_lib );

my $lib = locate_module_share_lib();

*print_hello = FFI::Raw->new($lib, 'hello_world', FFI::Raw::void)->coderef; 

Use it elsewhere:

use Foo::Bar;
Foo::Bar::hello_world();

DESCRIPTION

Module::Build variant for writing Perl extensions in C with FFI.

MACROS

If you include the header file ffi_util.h you can use these macros. The header file was first included with version FFI::Util / Module::Build::FFI 0.04, so you should be sure to make that a prerequisite in either your Build.PL or dist.ini (or both).

FFI_UTIL_VERSION

This is the FFI::Util version number multiplied by 100 (so it should be 4 for 0.04 and 101 for 1.01).

FFI_UTIL_EXPORT

The appropriate attribute needed to export functions from shared libraries / DLLs. For now this is only necessary on Windows when using Microsoft Visual C++, but it may be necessary elsewhere in the future.

SEE ALSO

FFI::Util
FFI::Raw
Module::Build

AUTHOR

Graham Ollis <plicease@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2013 by Graham Ollis.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.