in reply to Re^3: Passing undef to XSUB
in thread Passing undef to XSUB

I don't know much about XS, but I wonder if this code is able to distinguish between when it's passed undef and when it's passed 0. That is, can it see the difference between foo( undef, undef ) and foo( 0, 0 )? It seems to me the "uninitialized value" warning is undef getting turned into 0.

Replies are listed 'Best First'.
Re^5: Passing undef to XSUB
by syphilis (Archbishop) on May 08, 2008 at 07:57 UTC
    It seems to me the "uninitialized value" warning is undef getting turned into 0

    Yes, I think that's right:
    use warnings; use Inline C => Config => BUILD_NOISY => 1; use Inline C => <<'EOC'; void foo(int a) {} void bar(SV * a) {} void baz(SV * a) { int i = (int)SvIV(a); } EOC $u = undef; foo($u); # warning bar($u); # no warning baz($u); # warning
    Cheers,
    Rob