in reply to perl XS - passing array to C and getting it back

double do_nothing(double x[], int sizeOfX)

My advice is to install Inline::C and try this script:
use strict; use warnings; use Math::BigInt; use Inline C => Config => BUILD_NOISY => 1, USING => 'ParseRegExp', CLEAN_AFTER_BUILD => 0, ; use Inline C => <<'EOC'; double do_nothing(SV * x, ...) { dXSARGS; /* enable stack manipulation */ int index; for(index=0; index<items; index++) { printf("%f ", SvNV(ST(index))); ST(index)=newSVnv(1.34); } printf("\n"); return SvNV(ST(0)); } EOC my @in = (2.3, 3.4, 4.5, 6.8); my $d = do_nothing(@in); print $d, "\n"; my @next = (-1.7, -1.3, @in); my $d2 = do_nothing(@next); print $d2, "\n"; __END__ Outputs: 2.300000 3.400000 4.500000 6.800000 1.34 -1.700000 -1.300000 2.300000 3.400000 4.500000 6.800000 1.34
Because that script specifies CLEAN_AFTER_BUILD=>0 you can then cd into the ./_Inline/build directory and view the XS file that was autogenerated and used.
(I've never really learned how to write XS - I just use the XS file that Inline::C creates.)

There are of course, other ways to formulate do_nothing() - have a look at perldoc Inline::C-Cookbook for examples of the above and other perl API usage.
And see perldoc perlapi for documentation on the API functions.

In XS, it is allowable to pass a list of "double" types as arguments, but I think passing a variable-sized list of doubles (as you intended) would turn out to be messier than the above demo.
And that's why I've opted to pass the values as a list of "SV*" types.

You could also write do_nothing() as:
double do_nothing(SV * x) { ... do stuff }
In that case you'd be calling do_nothing() from perl as something like:
my $double = do_nothing(\@in);
I can give you a demo of that, too, if you like.

As a means to understanding the perl API, I really can't recommend Inline::C strongly enough.
It gives one the opportunity to quickly and easily trial constructs about which one is unsure - and is, IMO, the best available XS/API learning tool.

Cheers,
Rob