Hi there, I'm a newbie to perlXS. I have a C code which contains different structs
typedef struct { EntryType type; EntryIndex index; } TM_TranslationEntry; typedef struct { u64 EA, VA, RA; u8 pageSize; u32 numOfEntries; TM_TranslationEntry* entries; u32 modificationSet; } TM_PageTranslation; typedef struct { TM_InMemoryEntry* entries; u32 numOfEntries; } TM_InMemoryEntries; typedef struct { u64 slbee; u64 slbev; } TM_SlbEntry;
This is my typemap file:
TYPEMAP PageTranslation T_PTROBJ TM_InMemoryEntries T_PTROBJ TM_SlbEntry T_PTROBJ TM_TranslationEntry T_PTROBJ U64 T_UV
This is my trans.xs file header:
#include "EXTERN.h" #include "perl.h" #include "XSUB.h" #include "ppport.h" #include "TM_TranslationAPI.h" <--- include for the C code typedef struct TM_PageTranslation * PageTranslation typedef struct TM_InMemoryEntries * InMemoryEntries typedef struct TM_SlbEntry * SlbEntry typedef struct TM_TranslationEntry * TranslationEntry MODULE = trans PACKAGE = trans PROTOTYPES: ENABLE
and I have these functions inside the XS file which fails (only a sample):
InMemoryEntries selectMemoryEntriesSet(type) U64 type InMemoryEntries getEntryByType(pageTranslation, entryType) PageTranslation pageTranslation U64 entryType SlbEntry getSlbEntry(pageTranslation) PageTranslation pageTranslation
failing line:
Error: 'InMemoryEntries' not in typemap in trans.xs, line 167 Error: 'InMemoryEntries' not in typemap in trans.xs, line 172 Error: 'SlbEntry' not in typemap in trans.xs, line 176
I want to note one thing: prior to the functions which fails due to typemap issues, there are functions with PageTranslation which seems to pass (compiler does not give any errors/warning about them). As you can see, PageTranslation is also defined in the typemap. What am I doing wrong? **** update - found my mistake typemap naming should contain the names I chose for the struct and not the struct themselves (InMemoryEntries instead of TM_InMemoryEntries)

In reply to perl XS and C struct (works) by kopolov

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.