NAME

Inline::C2XS - create an XS file from Inline C or Inline CPP code.

SYNOPSIS

use Inline::C2XS qw(c2xs);

my $module_name = 'MY::XS_MOD';
my $package_name = 'MY::XS_MOD';
my $build_dir = '/some/where/else';

# Create /some/where/else/XS_MOD.xs from ./src/XS_MOD.c
c2xs($module_name, $package_name, $build_dir);

# Or create XS_MOD.xs in the cwd:
c2xs($module_name, $package_name);

Alternatively, if it's C++ code we're dealing with:

use Inline::C2XS qw(cpp2xs);

my $module_name = 'MY::XS_MOD';
my $package_name = 'MY::XS_MOD';
my $build_dir = '/some/where/else';

# Create /some/where/else/XS_MOD.xs from ./src/XS_MOD.cpp
# May also create /some/where/else/CPP.map if that file is
# going to be needed:
cpp2xs($module_name, $package_name, $build_dir);

# Or create XS_MOD.xs (and CPP.map, if needed) in the cwd:
cpp2xs($module_name, $package_name);

DESCRIPTION

Don't feed an actual Inline::C/CPP script to this module - it won't
be able to parse it. It is capable of parsing correctly only
that C/CPP code that is suitable for inclusion in an Inline::C/CPP
script.

For example, here is a simple Inline::C script:

 use warnings;
 use Inline C => Config =>
     BUILD_NOISY => 1,
     CLEAN_AFTER_BUILD => 0;
 use Inline C => <<'EOC';
 #include <stdio.h>

 void greet() {
     printf("Hello world\n");
 }
 EOC

 greet();
 __END__

The C file that Inline::C2XS needs to find would contain only that code
that's between the opening 'EOC' and the closing 'EOC' - namely:

 #include <stdio.h>

 void greet() {
     printf("Hello world\n");
 }

Inline::C2XS looks for the source file in ./src directory - expecting
that the filename will be the same as what appears after the final '::'
in the module name (with a '.c'/'.cpp' extension). ie if your module is
called My::Next::Mod the c2xs() function looks for a file ./src/Mod.c, 
and creates a file named Mod.xs. (The cpp2xs function looks for a file
./src/Mod.cpp and also creates a file named Mod.xs) Also created (by
both the c2xs and cpp2xs functions, is the file 'INLINE.h' - but only
if that file is needed. The generated xs file (and INLINE.h) will be 
written to the cwd unless a third argument (specifying a valid 
directory) is provided to the c2xs/cpp2xs function.

The created XS file, when packaged with the '.pm' file, an
appropriate 'Makefile.PL', and 'INLINE.h' (if it's needed), can be 
used to build the module in the usual way - without any dependence
upon the Inline::C/CPP module. The cpp2xs() function may also produce
a file named 'CPP.map'. That file, if produced, is also needed for a
successful build. See the demos/cpp folder in the Inline::C2XS source
for an example of what's required.

BUGS

None known - patches/rewrites/enhancements welcome.
Send to sisyphus at cpan dot org

COPYRIGHT

Copyright Sisyphus. You can do whatever you want with this code.
It comes without any guarantee or warranty.