[cffi-devel] detecting int size used by library
Juan Jose Garcia-Ripoll
juanjose.garciaripoll at googlemail.com
Wed May 26 12:02:38 UTC 2010
On Wed, May 26, 2010 at 1:42 PM, Tamas K Papp <tkpapp at gmail.com> wrote:
> Is there a way to detect the size of integers (ie 32 or 64 bit) used
> by a library?
>
The point is that you cannot even detect it so simply in C. If the library
is FORTRAN then you definitely have to introduce the knowledge of the type
size "by hand", because different compilers and different compiler options
will force the use of different type sizes.
If the library is in C and you have access to the headers then maybe
cffi-grovel can traverse the header and find it out, but I am not familiar
enough with that component and its preprocessing abilities (Atlas is likely
to use #defines and #ifdefs to choose the appropriate size).
Otherwise the usual and most reliable way to detect it is to do something
like autoconf does, which is to create a tiny C program, compile it with the
same flags as the library and detect the type size. You may even automate
this from lisp.
Juanjo
--
Instituto de Física Fundamental, CSIC
c/ Serrano, 113b, Madrid 28006 (Spain)
http://tream.dreamhosters.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/cffi-devel/attachments/20100526/adb580f4/attachment.html>
More information about the cffi-devel
mailing list