开发者

Delphi error appeared suddenly on one machine: E2056 String literals may have at most 255 elements, how is it possible?

开发者 https://www.devze.com 2023-01-19 23:40 出处:网络
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

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 did开发者_开发知识库n'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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消