Nice work !!
I'll draw attention to an oddity I've just noticed, of perhaps little significance.
Regarding the struct definition and typedef:
struct _Edje_Message_String_Set { int count; //On 64 bit machine, this is 8 bytes char *str[]; //str has no "size" and is not counted in sizeof(_Edj +e_Message_String_Set) }; typedef struct _Edje_Message_String_Set EdjeMessageStringSet;
The 'int' type is always 4 bytes on Windows, irrespective of architecture. And I think it's generally the same case on Linux.
IIRC, on Linux, it's usually the size of the 'long int' that varies with architecture - but 'int' usually stays at 4 bytes.

On 64 bit Windows, I'm finding that if char * str[]; is removed from the struct, then struct size is 4 bytes.
If char * str[]; is included, then the struct size is 8 bytes.
So it seems that "str" is increasing the size of the struct by 4 bytes. But that doesn't seem right to me.

Here's the demo I used:
use strict; use warnings; use Inline C => Config => BUILD_NOISY => 1, USING => 'ParseRegExp', ; use Inline C =><<'EOC'; typedef struct _foo { int count; } foo; typedef struct _bar { int count; char *str[]; } bar; void sizes(void) { printf( "FOO: %d %d\n", sizeof(struct _foo), sizeof( foo) ); printf( "BAR: %d %d\n", sizeof(struct _bar), sizeof( bar) ); printf( "INTSIZE: %d\n", sizeof(int) ); } EOC sizes(); __END__ On 64 bit windows, outputs: FOO: 4 4 BAR: 8 8 INTSIZE: 4
Maybe a bug in xsubpp ? Nope - it's just something that 64-bit gcc does on both Windows and Ubuntu. If it's a bug, then it's a gcc bug.

On 32-bit windows, it seems that char *str[]; does indeed make zero contribution to the size of the struct, and the same script outputs:
FOO: 4 4 BAR: 4 4 INTSIZE: 4
Cheers,
Rob

In reply to Re^8: Perl XS binding to a struct with an array of chars* by syphilis
in thread Perl XS binding to a struct with an array of chars* by MaxPerl

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.