[fpc-pascal] BoolToStr

Nikolay Nikolov nickysn at gmail.com
Mon Aug 29 13:36:38 CEST 2022

On 8/29/22 11:33, Jean SUZINEAU via fpc-pascal wrote:
> Le 29/08/2022 à 01:41, James Richters via fpc-pascal a écrit :
>> If a special function is needed for some COM thing or weird Winapi 
>> thing, then that function should be part of the unit that needs it, 
>> not modifying the generic function intended to be used for general 
>> purpose applications output something that does not conform to other 
>> Pascal Boolean datatypes and just confuses everyone.
> Unfortunately, it's not just a few windows functions which use this 
> behaviour but the whole Windows API:
> https://docs.microsoft.com/fr-fr/windows/win32/api/winuser/nf-winuser-getmessage?redirectedfrom=MSDN 
> The Microsoft BOOL datatype uses this convention so the whole 
> ecosystem is attracted to use it (other C program on windows, Delphi, 
> ... )
> I imagine it's more efficient at the assembler level to process the 
> result of functions returning boolean.

Or, it could be related to the (Visual) BASIC language. BASIC represents 
false as 0 and true as -1, and Microsoft have been a major developer of 
BASIC interpreters and compilers ever since their beginning. My guess 
is, they used -1 to ensure better interoperability between Visual C++ 
and Visual Basic.


More information about the fpc-pascal mailing list