Recent

Author Topic: [Solved] How to bypass compilation of unused Unit Lib in Project folder?  (Read 1240 times)

exilepanda

  • Newbie
  • Posts: 3
When I Run a program, it always compile all the Units found inside the project folder, however, it happens some units I am still constructing which may still contain errors.

Is there some project/compiler option that I can set to bypass the compilation of unused units ( units that never called in the main or the units dependent units ). I don't want to put them away only because I didn't finish because that will be part of the program at the end of day.

=====================================

Found that the problem was caused by I accidentally added the unit into the project, I can see that outstanding unit when I open Project Inspector ( OR the XML code of thatproject.lpr ) , which is not the matter I "uses" it or not in the main unit.
« Last Edit: June 13, 2024, 10:21:43 am by exilepanda »

ASerge

  • Hero Member
  • *****
  • Posts: 2337
Re: How to bypass compilation of unused Unit Lib in Project folder?
« Reply #1 on: June 13, 2024, 06:56:38 am »
Is there some project/compiler option that I can set to bypass the compilation of unused units ( units that never called in the main or the units dependent units ). I don't want to put them away only because I didn't finish because that will be part of the program at the end of day.
Strangely, this is actually exactly what you want, if the unit is not used anywhere in the project, then it is not compiled.
Apparently, the unit is listed somewhere in the project.

Thaddy

  • Hero Member
  • *****
  • Posts: 16158
  • Censorship about opinions does not belong here.
Mark your units that are not finished as experimental:
Code: Pascal  [Select][+][-]
  1. unit <whatevername> experimental;
That way you get a warning if such a unit is included somewhere in your project.
If you compile with -Sew it will be treated as an error.
If I smell bad code it usually is bad code and that includes my own code.

MarkMLl

  • Hero Member
  • *****
  • Posts: 8015
Found that the problem was caused by I accidentally added the unit into the project, I can see that outstanding unit when I open Project Inspector ( OR the XML code of thatproject.lpr ) , which is not the matter I "uses" it or not in the main unit.

I was going to point out that Lazarus (which you appear to be using, even though you don't tell us explicitly) automatically adds every unit in the project to the .lpr file... in fact this might well be what "being in the project" actually means. I think that the idea is to force the unit initialisation order to be deterministic, and for a unit that might not be needed (e.g. because you're not using it yet, or because it's not referenced until loaded dynamically) you can safely remove it or comment it out... frankly I prefer the latter if the removal is only temporary.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

Thaddy

  • Hero Member
  • *****
  • Posts: 16158
  • Censorship about opinions does not belong here.
I only use Lazarus is if I need a GUI, otherwise I use Geany on all platforms.
If I smell bad code it usually is bad code and that includes my own code.

exilepanda

  • Newbie
  • Posts: 3
Mark your units that are not finished as experimental:
Code: Pascal  [Select][+][-]
  1. unit <whatevername> experimental;
That way you get a warning if such a unit is included somewhere in your project.
If you compile with -Sew it will be treated as an error.

Thank you! This one is new to me, and it should be a very useful feature in later development!

 

TinyPortal © 2005-2018