[fpc-pascal] H2pas tool vs others, C header translation

Marco van de Voort marcov at stack.nl
Sun Aug 27 00:22:31 CEST 2017


In our previous episode, Michael Van Canneyt said:
> I think the programmer *must* worry about the details and must definitely
> NOT use the booleans for anything C related. That was my point.

The interface uses bool, either as param or in a structure. So what can you
do?
 
> Attempting to cater for C code using BOOL or whatever type is misplaced.
> C does not have a boolean type.

Since C99 it has:

https://stackoverflow.com/questions/4767923/c99-boolean-data-type

> The standard says for "if" :
> 
> "In both forms, the first substatement is executed if the expression
> compares unequal to 0."
> 
> Treat it as such.

All true, but futile, since one assumes the C side is not written by whoever
wants to interface it. He might not even have source.

And sometimes API don't adhere to above statement, and then having chosen
the right boolean type (longbool or boolean<x>) saves a lot of trouble.



More information about the fpc-pascal mailing list