This is the mail archive of the
libffi-discuss@sourceware.org
mailing list for the libffi project.
Is a Pointer identical to a Struct { Pointer }?
- From: "M.C.A. (Marco) Devillers" <marco dot devillers at gmail dot com>
- To: libffi-discuss at sourceware dot org
- Date: Wed, 15 Dec 2010 02:58:23 +0100
- Subject: 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