Just updated the program to take on board your helpful critique.
use strict; use warnings; my $point = pack 'f2', 1.2, 2.3; func(undef); # pass in 'NULL pointer' func($pointer); Inline C => <<'C_END'; typedef struct { float x, y; } Point; void func(SV *buf) { if (!SvOK(buf)) { printf("got a null pointer\n"); } else if (SvPOK(buf) && SvCUR(BUF) == sizeof(Point)) { Point *point = (Point *)SvPV_nolen(buf); printf("x=%.2f, y=%.2f\n"); } else { croak("invalid scalar"); } } C_END
In reply to Re^3: Inline::C and NULL pointers
by Chrysotoxum
in thread Inline::C and NULL pointers
by markong
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |