[fpc-pascal] C Enum vs. Integer

patspiper patspiper at gmail.com
Thu Sep 13 01:05:29 CEST 2012

On 12/09/12 20:11, Johann Glaser wrote:
> Hi!
> I'm working on a header translation for LibUSB and its fork libusbx.
> They define several data types as C enums (for examples, see
> http://libusbx.sourceforge.net/api-1.0/group__desc.html ).
> They excessively use direct assignment of enum values, and even use one
> value multiple times (e.g. LIBUSB_CLASS_PTP = 6, LIBUSB_CLASS_IMAGE =
> 6).
> Can I translate this 1:1, i.e., define an Enum in Pascal and just ignore
> the compiler warnings about reused values?
> Or should I rather define all these types as Integer and define
> constants for all values?
> One more question: In some C structs and function parameters and return
> values these enums are used too. How can I assure that the same memory
> allocation is used?
A translation of libusb 0.1.12 is available in the fpc contributed units 
(http://www.freepascal.org/contrib/contribs.html). Maybe you can use 
that as a reference.


More information about the fpc-pascal mailing list