Hi,
I have installed the Inline::C (0.43) and Inline::Struct (0.06) and I
still can't run the example code that contains a struct. Is there
something I am missing, like a ENV variable not set or something foolish
like that?
I pretty much gave up on using structs directly from Perl, but I can't
even define/create an instance of one from whithin the inline C call. It
however works if I have an include file. So here is the code that works:
PL
--
#!/usr/bin/perl
use Inline C => << 'ENDING';
#include<other.c>
void geta(int aa) {
int t = 4;
int a = outsider(aa);
Inline_Stack_Vars;
Inline_Stack_Reset;
Inline_Stack_Push(newSViv(a));
Inline_Stack_Push(newSViv(t));
Inline_Stack_Done;
}
ENDING
##takes in the output of the C call, returns a has with the values...
%ahash = &map_hash(geta(9));
print "$ahash{'t'} Tom $ahash{'a'}";
sub map_hash () {
$tmp{'a'} = @_[0];
$tmp{'t'} = @_[1];
return %tmp;
}
C include
--
typedef struct {
int dd;
}asf;
int outsider (int ddd) {
asf ssd;
ddd += 1;
ssd.dd = ddd;
return ssd.dd;
}
Now the combo above works, but its very ugly and its not what I wanted.
The code I thought I saw somewhere that worked would equate to:
#!/usr/bin/perl
use Inline C => << 'ENDING';
typedef struct {
int dd;
}asf;
void geta(int aa) {
int t = 4;
int a = aa;
asf aStruct;
aStruct.dd = a;
Inline_Stack_Vars;
Inline_Stack_Reset;
Inline_Stack_Push(newSViv(aStruct.dd));
Inline_Stack_Push(newSViv(t));
Inline_Stack_Done;
}
ENDING
##takes in the output of the C call, returns a has with the values...
%ahash = &map_hash(geta(9));
print "$ahash{'t'} Tom $ahash{'a'}";
sub map_hash () {
$tmp{'a'} = @_[0];
$tmp{'t'} = @_[1];
return %tmp;
}
This way I remove the unnecessary (in my opinion) C lib..
Any comments and info most appreciated!
Regards,
Tom Sienkiewicz
--