Lazarus
Free Pascal => Beginners => Topic started by: Birger52 on October 27, 2020, 05:22:39 pm
-
Have this little thing.
Compiler keeps adding a unit to uses clause - only to give a hint that is not used....
Why does it keep adding it then?
Think I've removed it at least 25 times...
-
The compiler does not anything, it's probably Lazarus that does this when you drop some component on the form (or datamodule).
Bart
-
Neither FPC nor lazarus have an unit checkdata.
Packages however can advise the IDE to add certain units that might be required for visual form editing to be added if a certain component is dropped on the form.
I would simply ignore the message, the package creator probably added the package for a reason.
-
If it really bothers you:
unit checkdata;
interface
implementation
end.
This dummy unit makes the message disappear
( we used the same technique in KOL for variants unit )
The linker will take care of this "overhead".. ;D
-
CheckData unit belongs to a component of mine.
It is not accessed directly by any programming in the program (form).
It may be Lazarus and not the compiler adding it - would make sense - ;)
But it always happens right after compiling, for some reason.
Lazarus is adding it, and compiler giving the hint?
I delete it from uses - and it reappears after next compile....
-
I could be wrong but when you create a component package there is an option to instruct the environment to automatically include any needed unit files in the uses list when using a component, maybe you placed that one in the list.
-
CheckData unit belongs to a component of mine.
It is not accessed directly by any programming in the program (form).
But is it used indirectly? E.g. does a type of a published property you have in one of your components come from that unit?
-
CheckData unit belongs to a component of mine.
It is not accessed directly by any programming in the program (form).
It may be Lazarus and not the compiler adding it - would make sense - ;)
But it always happens right after compiling, for some reason.
Lazarus is adding it, and compiler giving the hint?
I delete it from uses - and it reappears after next compile....
Sounds strange. AFAIK Lazarus adds units to a uses section when a component is dropped onto designer.
Compilation should not trigger it. I just tested removing a needed LCL unit from uses section. The result is a compilation error.
Can you upload a simple project to reproduce this please?
-
Sounds strange. AFAIK Lazarus adds units to a uses section when a component is dropped onto designer.
Sure does ;)
It's like this:
I have a long lidt of data that is either checked or not (True/False - Yes/No ...) with an option for tristate (Don't Care/Maybe) and a string attached.
User should be able to set all these (actually used for selecting from database).
So - I created a control to handle these items and a list of them.
The control accesses the list of items (unit CheckData defines as well items as the list to hold them), but the program (GUI) itself does not.
So unit CheckData is not needed in uses clause of application.
But Lazarus (or something else) adds it to the uses clause - and then issues a hint that it is not needed...
Checked the package - and the only thing I can find, is in Options/Usage at the bottom "add package unit to uses section" - it's unchecked, and it shouldn't add all units of the package, as understand the wording.
-
So - I created a control to handle these items and a list of them.
The control accesses the list of items (unit CheckData defines as well items as the list to hold them), but the program (GUI) itself does not.
So the types of some of the published properties are contained in CheckData?
So unit CheckData is not needed in uses clause of application.
But Lazarus (or something else) adds it to the uses clause - and then issues a hint that it is not needed...
Lazarus adds a reference to the unit, because it assumes that it is needed for correct access to the component for deserialization and such. However FPC - which is what issues the hint - does not care about that.
-
@Birger52, can you upload the package or a simplified version of it for testing?
Mattias who knows best the compiler integration and Codetools in Lazarus, says units are never added to uses section just before compilation.
-
@PascalDragon
So the types of some of the published properties are contained in CheckData?
Not really. They are accessed by the control. Not from the application itself.
Control takes a TStringList (or individual strings) where each string contain the label, the state (Y,N,T) and an optional id (Database), and custom-draws a field for the user to select - and the control tells app what to do (update selection from database) when control is closed (hidden) - and again with the data from the list transformed to strings.
@JuhaManninen
Can't really simplify ;)
And I will, when a get some time - might not be till monday.
(Still newbee so need to figure out how and what) ;)