This is the mail archive of the libffi-discuss@sourceware.org mailing list for the libffi project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Is a Pointer identical to a Struct { Pointer }?


Hi all,

This is a bit of a weird question regarding a quick-and-dirty fix.

In my language I use libffi extensively to interface with C. Since I
want to support strings in the language I want to discriminate between
pointers and pointers to characters in the libffi type information of
C functions called.

Now one quick-and-dirty hack I came up with is just wrapping a single
pointer in a structure as an 'encoding' of a char pointer. That
manner, I could discriminate between pointers and 'encoded' pointers
to characters easily.Of course, I would like to push values in the
normal manner to the C function called.

Now that scheme only works if a structure containing one pointer is
treated identically to a pointer in most calling conventions of GCC,
MVC, etc. on most OSes.

Is the latter true. I.e., is the same stack structure build for a
pointer, or a structure just holding a pointer? Is there an easier
manner to solve this?

Any help appreciated,
   Marco


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]