AlexeyT via fpc-pascal <fpc-pascal@lists.freepascal.org> schrieb am Mo., 4. Nov. 2019, 23:40:
> FPC 3.3.1-r43022 [2019/09/16] for Linux x64. This code crashes, because > fpc sees 'x', 'y' wrong: > > Py_BuildValue('{sLsisisisisisisOsOsOsisisisisisO}', > 'tag', > Mark.Tag, > 'x', > Mark.PosX, > 'y', > Mark.PosY, > 'len', > Mark.LenX, > > I must change it to this, it works ok: > Py_BuildValue('{sLsisisisisisisOsOsOsisisisisisO}', > 'tag', > Mark.Tag, > PChar(string('x')), > Mark.PosX, > PChar(string('y')), > Mark.PosY, > 'len', > Mark.LenX, > > Py_BuildValue is from Python-for-Lazarus package. > Py_BuildValue: function( format: PAnsiChar {;...}): PPyObject; > cdecl varargs; > 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. Regards, Sven >
_______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal