<div dir="auto"><div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">AlexeyT via fpc-pascal <<a href="mailto:fpc-pascal@lists.freepascal.org">fpc-pascal@lists.freepascal.org</a>> schrieb am Mo., 4. Nov. 2019, 23:40:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">FPC 3.3.1-r43022 [2019/09/16] for Linux x64. This code crashes, because <br>
fpc sees 'x', 'y' wrong:<br>
<br>
Py_BuildValue('{sLsisisisisisisOsOsOsisisisisisO}',<br>
'tag',<br>
Mark.Tag,<br>
'x',<br>
Mark.PosX,<br>
'y',<br>
Mark.PosY,<br>
'len',<br>
Mark.LenX,<br>
<br>
I must change it to this, it works ok:<br>
Py_BuildValue('{sLsisisisisisisOsOsOsisisisisisO}',<br>
'tag',<br>
Mark.Tag,<br>
PChar(string('x')),<br>
Mark.PosX,<br>
PChar(string('y')),<br>
Mark.PosY,<br>
'len',<br>
Mark.LenX,<br>
<br>
Py_BuildValue is from Python-for-Lazarus package.<br>
Py_BuildValue: function( format: PAnsiChar {;...}): PPyObject; <br>
cdecl varargs;<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">What did you expect? With varargs the compiler can't do any checks, thus the types are inserted as is and 'x' *is* a char or maybe a Pascal string, but by itself *never* a PChar. So the cast is the correct way. </div><div dir="auto"><br></div><div dir="auto">Regards, </div><div dir="auto">Sven </div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
</blockquote></div></div></div>