The integrated debugger is attempting to use some of the compiler helper functions to perform the requested evaluate. The linker, on the other hand, determined that the helper function was not actually used by the program and it did not link it into the program.
- Create a new application.
- Place a button on the form.
- Double click the button to be taken to the 'click' method.
- Add a global variable, 'v', of type String to the interface section.
- Add a global variable, 'p', of type PChar to the interface section.
The click method should read as:
- procedure TForm1.Button1Click(Sender: TObject); begin v := 'Initialized'; p := NIL; v := 'Abid'; end;
- Set a breakpoint on the second assignment to 'v'.
- Compile and run the application.
- Press the button.
- After the breakpoint is reached, open the evaluator (Run|Evaluate/Watch).
- Evaluate 'v'.
- Move the cursor to the 'New Value' box.
- Type in 'p'.
- Choose Modify.
The compiler uses a special function to copy a PChar to a String. In order to reduce the size of the produced executable, if that special function is not used by the program, it is not linked in. In this case, there is no assignment of a PChar to a String, so it is eliminated by the linker.
procedure TForm1.Button1Click(Sender: TObject);
v := 'Initialized';
p := NIL;
v := 'Abid';
v := p;
Adding the extra assignment of a PChar to a String will ensure that the linker includes the desired procedure in the program. Encountering this error during a debugging session is an indicator that you are using some language/environment functionality that was not needed in the original program.