一台机器上突然出现Delphi错误:E2056字符串文字可能最多有255个元素,怎么可能?
直到今天早上我都能够构建一个应用程序,然后我不知道当我尝试构建时发生了什么
[DCC Error] myunit.pas(1710): E2056 String literals may have at most 255 element`
如果这有效的话为什么会这样? (1710) 上个月未编辑。我和同事一一核对了项目选项和环境选项,都是一样的。 (唯一的区别是我安装了所有 Delphi 更新,而他没有安装,反正我今天没有安装它们)。
此外,如果我通过将字符串分成 2 来修复上述“错误”,
S := 'firstpart' + 'secondpart';
而不是
S := 'firstpartsecondpart';
// this is an example of course firstpartsecondpart
//is a string of more than 255 chars
做类似的事情,我就会遇到另一个问题:
[DCC Error] myunit.pas(1797): E2283 Too many local constants. Use shorter procedures
为什么会这样?我今天没有改变这个程序。这确实是一个很长的过程,但一直编译到今天早上。我尝试将程序分成 2 个,并且能够编译...
最后...
断点不再起作用。如果我尝试设置断点,在编译和链接后,断点的红色圆圈会变成带有 X 的绿色,就像当您尝试调试一行无法调试的代码时一样。
我尝试了所有方法,包括重新启动并将项目选项中的“调试信息”设置为“True”。
最后说明:由于某种原因,似乎应用了一些奇怪的设置。我不记得做过什么奇怪的事。最近我安装了 CnPack,但我可以有效地使用它几天。这个问题是从今天开始的。
有人可以帮我吗?我真的遇到了麻烦,我迷失了半天,但我仍然没有找到出路。
I was able to build one application up to this morning, then I don't know what happened as I try to build I have
[DCC Error] myunit.pas(1710): E2056 String literals may have at most 255 element`
Why this if this was working? (1710) was not edited in last month. I checked with a colleague project options and environement options one by one and they are the same. (the only difference is that i installed all Delphi updates, while he didn't anyway I didn't install them today).
moreover if I fix the above "erroor" by splitting the string in 2, doing something like
S := 'firstpart' + 'secondpart';
instead of
S := 'firstpartsecondpart';
// this is an example of course firstpartsecondpart
//is a string of more than 255 chars
I have another problem:
[DCC Error] myunit.pas(1797): E2283 Too many local constants. Use shorter procedures
Why this? I didn't change this procedure today. It is a long procedure indeed, but it used to compile up to this morning. I tried to split tjhe procedure in 2 and I was able to compile...
And Finally...
Breakpoints doesn't work anymore. If I try to set a breakpoint, after compiling and linking the RED cirlce of breaxpoint becomes green with an X, like when you try to debug a line of code that cannot be debugged.
I tried all, including rebooting and setting Debug Info to True in project options.
FINAL NOTE: It seems that for some reason some strange settings have been applied. I can't recall having done something strange. Recently I installed CnPack, but I could use it effectively for days. This problem started today.
Can anyone give me an hand? I am in real trouble, I lost half day and I still don't see a way out.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您似乎已经更改了“巨大的字符串”项目选项。您是否在代码中添加了 {$H} ?或者你是否摆弄了项目选项? (需要检查“编译器选项/大字符串”以默认为长度超过 255 个字符的字符串。)
绿色断点意味着该特定代码未编译,因此不会被调用。检查您的代码是否正在调用此代码,或者它是否正在查看其他(预编译的?)单元。
My comments from below to complete the answer:
If all breakpoints are green, it appears you have a problem setting the project options. If you remove the YourProject.dproj and YourProject.dproj.local files (Move somewhere else, don't delete) and then open the YourProject.dpr, your project should have the default options. Check if it works in that case. If not, move the old files back.
The E2056 error is because strings inside Delphi code cannot be longer than 255 characters. Splitting it by including '+' in your string can fix this. See qc.embarcadero.com/wc/qcmain.aspx?d=71575 for why your collegue doesn't get this warning.
It seems you've changed the "Huge strings" project option. Did you add a {$H} to your code? Or did you fiddle with the project options? ("Compiler options/Huge strings" need to be checked to default to strings longer than 255 characters.)
The green breakpoint thingie means that this specific code is not compiled, thus it will not be called. Check if your code is calling this code, or perhaps it's looking at some other (pre-compiled?) unit.
My comments from below to complete the answer:
If all breakpoints are green, it appears you have a problem setting the project options. If you remove the YourProject.dproj and YourProject.dproj.local files (Move somewhere else, don't delete) and then open the YourProject.dpr, your project should have the default options. Check if it works in that case. If not, move the old files back.
The E2056 error is because strings inside Delphi code cannot be longer than 255 characters. Splitting it by including '+' in your string can fix this. See qc.embarcadero.com/wc/qcmain.aspx?d=71575 for why your collegue doesn't get this warning.