Recent

Author Topic: Unit not used  (Read 741 times)

Birger52

  • Sr. Member
  • ****
  • Posts: 295
Unit not used
« 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...
Lazarus 2.0.8 FPC 3.0.4
Win7 64bit
Playing and learning - strictly for my own pleasure.

Bart

  • Hero Member
  • *****
  • Posts: 4034
    • Bart en Mariska's Webstek
Re: Unit not used
« Reply #1 on: October 27, 2020, 05:39:28 pm »
The compiler does not anything, it's probably Lazarus that does this when you drop some component  on the form (or datamodule).

Bart

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8898
  • FPC developer.
Re: Unit not used
« Reply #2 on: October 27, 2020, 07:39:44 pm »
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.

Thaddy

  • Hero Member
  • *****
  • Posts: 10574
Re: Unit not used
« Reply #3 on: October 27, 2020, 08:06:21 pm »
If it really bothers you:
Code: Pascal  [Select][+][-]
  1. unit checkdata;
  2. interface
  3. implementation
  4. 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
« Last Edit: October 27, 2020, 08:55:10 pm by Thaddy »

Birger52

  • Sr. Member
  • ****
  • Posts: 295
Re: Unit not used
« Reply #4 on: October 28, 2020, 12:56:16 am »
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....
Lazarus 2.0.8 FPC 3.0.4
Win7 64bit
Playing and learning - strictly for my own pleasure.

jamie

  • Hero Member
  • *****
  • Posts: 3791
Re: Unit not used
« Reply #5 on: October 28, 2020, 10:03:31 pm »
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.

The only true wisdom is knowing you know nothing

PascalDragon

  • Hero Member
  • *****
  • Posts: 2418
  • Compiler Developer
Re: Unit not used
« Reply #6 on: October 29, 2020, 09:27:22 am »
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?

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3886
  • I like bugs.
Re: Unit not used
« Reply #7 on: October 29, 2020, 11:22:11 am »
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?
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux.

Birger52

  • Sr. Member
  • ****
  • Posts: 295
Re: Unit not used
« Reply #8 on: November 12, 2020, 06:36:35 pm »
Quote
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.
Lazarus 2.0.8 FPC 3.0.4
Win7 64bit
Playing and learning - strictly for my own pleasure.

PascalDragon

  • Hero Member
  • *****
  • Posts: 2418
  • Compiler Developer
Re: Unit not used
« Reply #9 on: November 13, 2020, 02:56:59 pm »
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.

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3886
  • I like bugs.
Re: Unit not used
« Reply #10 on: November 13, 2020, 11:46:08 pm »
@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.
« Last Edit: November 14, 2020, 10:31:45 am by JuhaManninen »
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux.

Birger52

  • Sr. Member
  • ****
  • Posts: 295
Re: Unit not used
« Reply #11 on: November 14, 2020, 07:23:11 pm »
@PascalDragon
Quote
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) ;)

Lazarus 2.0.8 FPC 3.0.4
Win7 64bit
Playing and learning - strictly for my own pleasure.

 

TinyPortal © 2005-2018