Forum > General

[Solved] How to bypass compilation of unused Unit Lib in Project folder?

(1/2) > >>

exilepanda:
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.

ASerge:

--- Quote from: exilepanda on June 13, 2024, 03:26:53 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.

--- End quote ---
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:
Mark your units that are not finished as experimental:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---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.

MarkMLl:

--- Quote from: exilepanda on June 13, 2024, 03:26:53 am ---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.

--- End quote ---

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

Thaddy:
I only use Lazarus is if I need a GUI, otherwise I use Geany on all platforms.

Navigation

[0] Message Index

[#] Next page

Go to full version