admin管理员组

文章数量:1314571

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?

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?

Share Improve this question edited Jan 30 at 16:50 Remy Lebeau 598k36 gold badges503 silver badges848 bronze badges asked Jan 30 at 13:07 Robe79Robe79 575 bronze badges 2
  • Why did you remove "1" (and renumbered "2" to "1")? – HeartWare Commented Jan 30 at 13:41
  • @HeartWare Because unrelated questions should be asked separately. The first question warrants its own post. – Remy Lebeau Commented Jan 30 at 16:55
Add a comment  | 

1 Answer 1

Reset to default 1

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.

本文标签: delphiImplicit string cast with potential data loss from 39string39 to 39ShortString39Stack Overflow