On 2017-08-26 17:22, mar...@stack.nl wrote:
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.
Another option is to write BOOLEAN wrappers around the lower level
functions that interface in to the DLL
So for example, could even use an INTEGER, as the boolean, as the Jedi
fellow sometimes does, then write a wrapper around it that makes use of
a proper boolean. All this, though, is a headache and obnoxious, tedious
.
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal