In Delphi 7, PChar
is an alias for PAnsiChar
. That is, pointer to 8 bit ANSI character. Which means that RecBuf[0]
has type AnsiChar
. Since AnsiChar
and Boolean
have the same size, the cast is valid.
In Delphi XE5, PChar
is an alias for PWideChar
, pointer to 16 bit wide character. And so RecBuf[0]
has type WideChar
. Thus the cast is invalid because WideChar
and Boolean
have different size.
Exactly how best to fix the problem cannot be discerned from the code that you have shown here. Quite possibly you need to redeclare RecBuf
. Perhaps it needs to be declared as PAnsiChar
. Although one does wonder why you are casting a character to a Boolean
.
Another possibility is that the reason RecBuf
is declared as PChar
is to allow you to use the index operator []
, something that in older versions of Delphi is a special capability of pointers to character types. In modern Delphi you can use {$POINTERMATH ON}
to enable that functionality for all typed pointers. So, if you did that then perhaps RecBuf
should be PBoolean
.
The bottom line is that whilst we can explain why the compiler complains about your code, we cannot give you a definitive solution.