[fpc-pascal] Some RTL functions cry big tears when mixing Pchar and Ansistring/String
md at rpzdesign.com
md at rpzdesign.com
Tue Jun 11 04:49:36 CEST 2013
Under Linux using Lazarus 1.0.8/Fpc 2.6.2/Fedora 14 x64:
it seems like mixing Ansistrings and Pchars on certain run time
functions is a real no-no.
I just spent HOURs, trying to see why I was not getting good program
behavior.
Lesson #1: Never call function like Copy( pchar, start, length),
ONLY use Copy( ansistring/string, start, length)
Other functions like PosEx( ) do not generate compiler
errors but you really do NOT want a Pchar to this function,
only an ansistring/string.
Passing a Pchar gives weird, erratic behavior
Maybe the RTL library team could put compiler WARNINGS about only
allowing for strings/ansistrings
on copy( ), posex( ), and other functions who have really no business
taking pchar arguments.
Cheers,
md
More information about the fpc-pascal
mailing list