jeanba has asked for the wisdom of the Perl Monks concerning the following question:

Hello, I have to bind a C library with struct inside. I read the most common help (struct netconfig Netconfig;....) But it doesn't work...damned , each time a do the make of my module i have a "Bad pointer type in paramater number 1" . the header is like it
typedef struct { unsigned *char test;} s_test; extern void my_function(s_test * my_struct);
Please tell me how to map a simple C struct in perlxs and the steps to do it right. thank you very much. jeanba

Replies are listed 'Best First'.
Re: mapping a C structure with perlXS
by Joost (Canon) on May 20, 2005 at 14:05 UTC
      yes excuse me , i forgot the most important... the xs file is like this (exactly) :
      #include "EXTERN.h" #include "perl.h" #include "XSUB.h" #include "ppport.h" #include "test.h" typedef struct s_test Test; MODULE = Tests PACKAGE = Tests void my_function(ptr_struct) Test * ptr_struct
      and in thetypemap file i added the following line :
      Test * T_PTROBJ
      thank you very much
        Note that your s_test is a type:
        typedef struct { unsigned *char test;} s_test;
        not a struct (which is anonymous here). So you'd probably better:
        typedef s_test Test; /* Removed "struct" */
        and see if this fixes your problem.

        Flavio (perl -e 'print(scalar(reverse("\nti.xittelop\@oivalf")))')

        Don't fool yourself.