Recent

Author Topic: Codetools bug  (Read 481 times)

440bx

  • Hero Member
  • *****
  • Posts: 5477
Codetools bug
« on: May 13, 2025, 06:58:36 pm »
Hello,

The attachment has 2 projects.  One where codetools works as expected and the other one where codetools doesn't.  The _only_ difference between the two projects is that in project A, all the files are in the same directory whereas in project B, the unit and the program are in different directories.

Specifically, in project A, the program peb.lpr is in the same directory as winapi.pas (a unit it uses), whereas in project B, peb.lpr is in a sub directory called PEB while the unit winapi.pas is in the parent directory.

The problem is that when the program and the unit are not in the same directory, codetools can no longer figure out where things are.  For instance, if you ask it to locate some function, it won't be able to, instead it complains that it cannot find the winapi unit.

The attached file, which demonstrates the problem, should be extracted in a clean directory, it will create subdirectories A & B. 

In directory A, compile WinApiBuild using WinApiBuild.lpi, then compile peb using peb.lpi.  In any of the files peb uses, tell codetools to find the function emit_LabelAndValue and it will find it without any problem.

In directory B, follow the same steps, compile WinApiBuild using WinApiBuild.lpi then in directory PEB, compile peb using peb.lpi.  In any of the files peb uses, tell codetools to find the function emit_LabelAndValue, it will not be able to find it and it will complain that it cannot find winapi.

Also, the problem causes codetools to no longer emit hints about what parameter(s) a function/procedure takes.

Comments and questions welcome.


ETA:

added (s) to the word parameter.


« Last Edit: May 13, 2025, 07:06:51 pm by 440bx »
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v4.0rc3) on Windows 7 SP1 64bit.

440bx

  • Hero Member
  • *****
  • Posts: 5477
Re: Codetools bug
« Reply #1 on: May 19, 2025, 11:39:57 pm »
Finally figured out the proper solution to this problem.

Just in case someone else experiences this problem, here is the cause and the solution.

The problem is caused by the failure to specify the directory for "Other sources" in the Compiler Options/Build mode setting.

Refer to the attachment.

The ".." in "Other sources (.pp/.pas files, ...) was missing causing codetools to be unable to locate the winapi.pas unit.  Once ".." is specified in that field, everything works as expected.

Credit and a thank you goes to @WooBean for pointing out one solution to the problem.

HTH.
« Last Edit: May 19, 2025, 11:50:04 pm by 440bx »
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v4.0rc3) on Windows 7 SP1 64bit.

 

TinyPortal © 2005-2018