[fpc-pascal] C Enum vs. Integer
Jonas Maebe
jonas.maebe at elis.ugent.be
Wed Sep 12 20:44:21 CEST 2012
On 12 Sep 2012, at 19:11, Johann Glaser wrote:
> 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?
It depends on whether you need arithmetic or not. If you do, use integer constants, otherwise you can use an enum.
> 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?
Include an appropriate {$packenum xxx} directive in your source code. There is no {$packenum c} (I'm not even sure whether the C standard says anything about the size of enums), so you'll have to check the size of those enumeration types in C yourself.
Jonas
More information about the fpc-pascal
mailing list