Robe79
Robe79

Reputation: 21

Implicit string cast with potential data loss from 'string' to 'ShortString'

I have several assignments like this (example):

string[50] := string + string

The length of string is mandatory (50...20...10...). This warning is generated:

W1058 Implicit string cast with potential data loss from 'string' to 'ShortString'

What cast can be done to eliminate this warning?

Upvotes: 0

Views: 108

Answers (1)

HeartWare
HeartWare

Reputation: 8243

To eliminate (suppress - ie. not a fix) the warning, do an explicit type cast to ShortString:

string[50] := ShortString(string + string)

But, you are only suppressing the warning. If string (or string) contain characters that can't be represented in 8-bit in your current locale, you'll get '?' characters instead.

As you can see, it's an uphill battle to try to force the UNICODE compiler to work in ANSI mode. You would be much better off to simply convert your code to full UNICODE from the bottom up.

Upvotes: 1

Related Questions