C::Blocks::Types - type classes for basic C data types for C::Blocks


This documentation is for v0.40_1


 use C::Blocks;
 use C::Blocks::Types qw(double double_array Int);
 # Generate some synthetic data;
 my @data = map { rand() } 1 .. 10;
 print "data are @data\n";

 # Pack this data into a C array
 my double_array $points = pack 'd*', @data;
 # Calculate the rms (root mean square)
 my double $rms = 0;
 cblock {
     for (int i = 0; i < length_$points; i++) {
         $rms += $points[i]*$points[i];
     $rms = sqrt($rms / length_$points);
 print "data rms is $rms\n";
 # Note that Int is capitalized, unlike the other type names
 my Int $foo = 4;
 cblock {
     printf("$foo is %d\n", $foo);


C::Blocks lets you intersperse blocks of C code directly among your Perl code. To help facilitate the interchange of C and Perl data, you can indicate that your Perl variable has an associated type package. This is discussed in "TYPES" in C::Blocks. The purpose of this package is to provide type packages, and short names, for basic C data types like double and short, as well as rudimentary packed arrays.

... must document provided types as well as "length_" variables.