On Wed, Jun 17, 2009 at 02:30:07PM -0400, Divya Krishnan wrote:
> Is there an appropriate API in cil that when passed a type like say a
> struct/union will return the correct size of that type as an integer
> value.  The one I could find was : val sizeOf :
> typ<http://manju.cs.berkeley.edu/cil/api/Cil.html#TYPEtyp>-> exp
> <http://manju.cs.berkeley.edu/cil/api/Cil.html#TYPEexp> but this
> returns an exp.

Looking for "sizeof" in the Cil API documentation, first hit:

  CIL is configured at build-time with the sizes and alignments of the 
underlying
  compiler (GCC or MSVC). CIL contains functions that can compute the size of a
  type (in bits) Cil.bitsSizeOf, the alignment of a type (in bytes)
  Cil.alignOf_int, and can convert an offset into a start and width (both in
  bits) using the function Cil.bitsOffset. At the moment these functions do not
  take into account the packed attributes and pragmas.

And below:

  val bitsSizeOf : typ -> int
  The size of a type, in bits. Trailing padding is added for structs and arrays.
  Raises Cil.SizeOfError when it cannot compute the size. This function is
  architecture dependent, so you should only call this after you call
  Cil.initCIL. Remember that on GCC sizeof(void) is 1!

Regards,
-- 
Gabriel Kerneis

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing 
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
CIL-users mailing list
CIL-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cil-users

Reply via email to