declaring C enum types

John Meacham john at repetae.net
Thu Oct 17 05:25:44 EDT 2002


I am pretty sure that ISO C says that enums are equivalant to ints
always. of course, not all implementations may be ISO C compliant.
	John

On Thu, Oct 17, 2002 at 10:01:56AM +0100, Keith Wansbrough wrote:
> > 
> > >     - If not, then how should enum values be declared in the FFI?
> > 
> > What you need to do is run a little autoconf-like program which
> > constructs a program containing a suitable example, runs it through a
> > C compiler and tells you what's going on.
> > 
> > hsc comes very close but I'm not certain if it does exactly what you
> > need.  If not, compiling and running this program should tell you:
> 
> Hmm, careful.  The C compiler is free to be clever, and use a char if there are <=256 elements in the enum, and short or int otherwise.  You want to know the size of your particular enum, not any random enum.
> 
> (betraying my age, but didn't Turbo C do this?)
> 
> --KW 8-)
> -- 
> Keith Wansbrough <kw217 at cl.cam.ac.uk>
> http://www.cl.cam.ac.uk/users/kw217/
> University of Cambridge Computer Laboratory.
> 
> _______________________________________________
> FFI mailing list
> FFI at haskell.org
> http://www.haskell.org/mailman/listinfo/ffi

-- 
---------------------------------------------------------------------------
John Meacham - California Institute of Technology, Alum. - john at foo.net
---------------------------------------------------------------------------



More information about the FFI mailing list