Subject: | SYNOPSIS code does not work for me |
When I run the exact code in the SYNOPSIS section I get this:
iscah% perl synopsis.pl
Can't locate object method "new" via package "Inline::Struct::Foo" (perhaps you forgot to load "Inline::Struct::Foo"?) at synopsis.pl line 3.
Was able to get the (I believe) intended behavior by passing in the C code to the use line, and by adding a "typedef struct Foo Foo":
use Inline C => <<'...' => structs => ['Foo'];
struct Foo {
int num;
char *str;
};
typedef struct Foo Foo;
void myfunc(Foo *f) {
printf("myfunc: num=%i, str='%s'\n", f->num, f->str);
}
...
Without the typedef the error is:
...
...
...
synopsis_pl_28e5.xs:105:13: error: must use 'struct' tag to refer to type 'Foo'
void myfunc(Foo *f) {
^
struct
1 error generated.
make: *** [synopsis_pl_28e5.o] Error 1
...
...
...
Changing the myfunc signature to "void myfunc(struct Foo *f)" allowed it to compile correctly, but hid the myfunc():
iscah% perl synopsis.pl
Undefined subroutine &main::myfunc called at synopsis.pl line 16.
Also, the README that ships with this dist appears to be old, and provides an example that also does not work.