Answer the question
In order to leave comments, you need to log in
Variable problem in Delphi. What to do?
Declared a variable of type boolean in a function. Delphi sees it, but when debugging, it skips all the operations associated with it, and also displays a message that this variable is not used in the program. Rewrote the .exe file, didn't help.
Answer the question
In order to leave comments, you need to log in
> they say this variable is not used in the program
That's right, and the memory (or register) is not allocated for it.
Take a close look at your code, maybe you have a complex boolean expression that is evaluated at compile time - and that's it.
In VisualStudio, when trying to debug a project compiled under the release configuration, there were sometimes such problems. Make sure you are using the debug config
If Delphi reports that the variable is not being used, it probably is.
The compiler most often analyzes whether there are data accesses inside the variable and, based on the result of this analysis, decides whether the variable is needed in the code.
Example1:
var
a: boolean;
<...>
begin
a:= false;
<...>
a:= true;
<...>
end;
var
a: boolean;
<...>
begin
a:= false;
<...>
a:= true;
<...>
return a;
end;
If you look for where to turn off "optimization", then try to put in a thread if (variable = true) then inc (k);
in order for there to be any action that depends on the variable, it will have to eventually include it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question