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
1 Answer
Reset to default 1To 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
版权声明:本文标题:delphi - Implicit string cast with potential data loss from 'string' to 'ShortString' - Stack Ov 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741963081a2407396.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论