Is there any possibility to make compiler continue when errors are encountered during the compilation an application in D2006? I want to know how many errors it finds on an application.
No there is not. The problem is that once the compiler can't compile one unit, it's in no position to compile the other ones that, more than likely, depend on the unit that could not be compiled. This is because compilation of a unit requires a .dcu file for all of the used units.
Related
Delphi 10 Seattle introduces Winapi.Security.pas. The project (a package) I'm trying to upgrade already has a Security.pas file. Short of removing Winapi from the list of scope names for the project (huge undesirable ripple effect), is there a way to tell the IDE and compiler to use the project's Security.pas file instead of Winapi.Security.pas?
I already tried renaming the projects Security.pas, but that caused even more problems with the compiler generating errors that have nothing to do with the code it was complaining about, so that's a rathole I'd rather not go down right now. This project builds just fine unchanged in XE7, FWIW, so this isn't due to any code changes in the project.
Updates:
Renaming the file and using a unit alias doesn't work.
The compiler behavior for a package differs from an application.
Looks like this might actually be related to the Winapi.Security unit rather than something as generic as you suggest in the question. For instance, the following package compiles just fine:
package Package1;
requires
rtl;
contains
Windows in 'Windows.pas'; // blank unit named Windows.pas in project folder
end.
Note that I have, like you, included Winapi in the project's list of unit scope names.
On the other hand, this package does not compile:
package Package1;
requires
rtl;
contains
Security in 'Security.pas'; // blank unit named Security.pas in project folder
end.
The compiler fails with:
[dcc32 Error] Package1.dpk(7): E2200 Package 'rtl' already contains unit 'Winapi.Security'
If the issue was purely related to unit scope names then either both packages would compile, or both would fail. Hence my conclusion that there is something out of whack with Winapi.Security.
I can find no source code for Winapi.Security. I wonder what it actually is. [Nicholas Ring located the source for me, inside the rtl\win\winrt directory.]
Anyway, I think it's time to submit a QP report. The package below that fails to compile is probably the starting point for that QP report. [Your submitted report is here RSP-12469.]
It seems clear to me that in the short term you must rename your unit if you wish to adopt Seattle.
FWIW, here are some other units that behave the same way as Winapi.Security:
Winapi.ApplicationModel
Winapi.CommonTypes
Winapi.Devices
Winapi.Foundation
Winapi.Gaming
Winapi.Globalization
Winapi.GraphicsRT
Winapi.Management
Winapi.Media
Winapi.Networking
Winapi.Storage
Winapi.UI
Winapi.WebRT
These are all newly added WinRT units which I expect is important.
If you put both Winapi.Security and your local Security in the same uses clause then you are able to access the members of both of them without issue. If you put them in separate uses clauses (Interface vs. Implementation) then you will get the error:
E2004 Identifier redeclared: 'Winapi.Security'
If I only include Security.pas in the uses clause (and it is included in the project) then it accesses its members just fine.
Perhaps I need more information about what error you are running into? I'll send you a sample project that shows this working.
I might well be wrong, but I believe that if Security.pas is in the uses clause of the dpr file, along with its full path, it will be preferred over whichever file can be found via the namespaces and search paths.
Open project settings, in the Delphi Compiler section remove "Winapi" from "Unit scope names".
This way, when you need the Security unit shipped with Delphi, you'll have to write Winapi.Security, and if you write Security, it will use your custom Security unit.
I've just did a migration from XE3 to XE6.
Now I'm stuck with compile error [dcc32 Fatal Error] e.pas(6): F1026 File not found: 'XSLProd.dcu'. On XE3 this unit is under the path Embarcadero\RAD Studio\10.0\source\internet.
But under the same folder on XE6 there is no unit named like that.
I've search the whole folder for XslProd.pas file and the result was 0.
Does anybody know what happend to this unit - I guess there is a chance that this unit was removed some version prior to XE6.
This unit was removed in XE5. The classes that it contained are not to be found in any other unit in the source folder so one can only conclude that, either:
Embarcadero decided to remove the unit from the product for some reason, or
The unit was somehow removed by accident.
My guess is that the former is the case, that the unit was removed intentionally. And that the reason for doing so related to the development of the new mobile platforms.
The error I get is like this:
[DCC Fatal Error] myunit3.pas(244): E2411 Unit XBAT in package B_Dsgn refers to unit QBEE which is not found in any package. Packaged units must refer only to packaged units
I need to know what this error I am encountering really means, and if possible how to troubleshoot and solve such problems, especially when the facts stated in the error message are not correct (the units are in fact referring to other units in other valid packages).
Such problems involve package dependencies. I am having an interesting problem with a series of three designtime and three runtime packages related like this:
What is most odd about it is that each time I clean and rebuild, I get a different unit name in the error. (Shown above as Unit XBAT refers to unit QBEE).
The other odd thing is that it's referring to units that are in a top level dependency, and are part of a package that was already built.
Steps;
Compile A, it works.
Compile A_Dsgn, it works.
Compile B, it Works.
Compile B_Dsgn, it works.
Compile C, and it fails with this E2411 error.
Since I doubt anybody can tell me how to fix this exactly, I am looking for the steps to troubleshoot a complex dependency problem in a package. The literal meaning of the above error suggests for example, that I should have a corresponding message about an implicit linked unit, which I do not have. I have added all implicitly used units to the base packages A, and B, so that no implicit unit warnings are made.
My next idea was to separate the DCU output folders for each package, to prevent the DCU outputs from one from confusing the compiler. Now I can not even build the packages.
Update I tried playing with the Explicit Rebuild and Rebuild as Needed options. I have found that this error is related to having 'Rebuild as Needed' turned on. When it is turned off, the packages fail with other errors which are more to the point. I find it odd that the compiler emits weird errors that can be disabled by turning off Rebuild as needed. Any ideas what is going on?
Update 2 The basic underlying problem is not solved by turning on or off explicit rebuild. Instead of getting this error, I get annoying runtime/designtime package problems, which result in a set of packages, that can not be loaded at the same time. (Can not load package foo because it contains unit bar which is also in package bat. Do you want to attempt to load this package the next time a project is loaded?).
I suspect it is an obscure compiler bug.
The project I experienced it in had at least 4 levels of dependent runtime packages:
PackageA <- PackageB <- PackageC <- PackageD
E2411 Unit '%s' in package PackageD refers to unit '%s' which is not
found in any package. Packaged units must refer only to packaged units.
The only solution I found that worked was to make packages A, B and C never-build (i.e. Explicit Build) packages and use Project Dependencies to enforce build order instead. I had to make all three never-build or I would get
E2220 Never-build package '%s' requires always-build package '%s'
I know its probably not the answer you were looking for but there it is.
Btw, this happened to me in Delphi 2009.
It is quite simple: If a unit in C refers to a unit not in any package referred to by package C, that unit should be included in C, or the package in which it can be found should be referenced by C. If necessary, put the unit in a package of its own.
Where you put which unit depends on the dependencies. It makes sense to draw it out, like you did, but with a unit level resolution.
Update
Your update 1 and update 2 still make me think there is a unit one of your units uses (directly or indirectly) that is not properly referenced. Perhaps even an RTL or VCL unit. Since you have design packages, I assume you have components in them.
IME, the minimum set of packages to include is
requires
rtl,
designide,
vcl,
vclactnband,
vclx,
xmlrtl;
In the project that gives the error must be added as required the. dcp error.
In your case:
[DCC Fatal Error] myunit3.pas (244): E2411 Unit in package B_Dsgn XBAT Refers to unit QBEE Which is not found in Any package. Must Refer Packaged units only to packaged units
In the package where it myunit3.pas drive, add in required: QBEE
At least I managed to do so.
You are using the QBEE unit in the unit XBAT, in this case you have foure options:
1- you didn't add the QBEE to the contains list in the Package B_Dsgn.
2- If QBEE is already containd in another Package lets call it Original_Package then you should add the Package to the requires list in B_Dsgn and not contain the unit.
3- the Original_Package has
{$IMPLICITBUILD ON}
in it's dpk file so first what you have to do is to turn IMPLICITBUILD off and build Original_Package after that you can build your B_Dsgn package.
4-you probably didn't have XBAT in B_Dsgn but you have it in another middle package lets call it B_Run and you have B_Run in the requires list of B_Dsgn, in this case try first to fix B_Run with one of the upper three options and then build it, after that you can build B_Dsgn.
Note:
the last two cases could be reproduced with a long list of units and not just two or three packages that are requiring each other, in this case all of the packages should have IMPLICITBUILD off.
Clean the code for every single package of the packages that effect the issue before building them.
good luck
Is there a way to force the Delphi compiler to display all hints and warnings all the time?
Here is the behavior that I am currently seeing in Delphi 6:
Check out fresh copy of my application from source control
Open project in Delphi and Compile
All hints and warnings for the project are displayed
Make a change in one unit
Compile
Only the hints and warnings for the changed unit are displayed
So, I thought maybe I can trick Delphi by deleting all of the dcu files to force it to recompile everything. No luck. The compiler does in fact recompile all of the units, but does not display the hints and warnings for those units.
EDIT: Performing a full build (Project > Build) yields the same unfortunate results.
NEW INFORMATION: If I modify a unit and then Compile, I get the warnings. However, if I modify a unit and then Build, I do not get the warnings. I'm thinking this points to warnings being turned off somewhere. Possibly in a third party library?
It seems there ought to be a way to ask Delphi to re-display all of those hints and warnings that doesn't require me to either check out a fresh copy from source control or modify each unit one-by-one.
Hints and Warnings are generated by the compiler. It will only report on units that it has compiled. The "compile" command will only compile files that have changed. To force a recompilation of all units used by your project, use the Build command instead.
Later versions assign a shortcut key (Shift+F9) to the "Build" command.
To get that keyboard shortcut in Delphi 6, install this utility, which I've used for a while with great success on Delphi 5.
I would check to see if you turn the warnings off in some of your units.
Depending on the last change in the units, the compiling order can change. In some cases the warnings can remain disabled for a unit that is compiled after while, when freshly checked out of version control, it was compiled before, with the warnings.
Pay extra attention to any Include file you may use.
I had the same problem and finally i found solution... Search for strings $WARNINGS OFF and $HINTS OFF, and not just from *.pas files but from all the files. I had this strange idea in third-party .inc file:
{$IFDEF DEBUG}
{$WARNINGS ON}
{$HINTS ON}
{$ELSE}
{$WARNINGS OFF}
{$HINTS OFF}
{$ENDIF}
If you use dcc32.exe, all warnings will be shown, always. (This is another reason why I use build scripts for all my projects.)
I am still using D6 for some projects and if I do a full build then all hints and warnings are displayed/re-displayed. For syntax check or compile only changed unit messages are displayed.
You have something else wrong or damaged somewhere. Try deleting the project .dsm and the .dof files (they will be rebuilt) the .dof file contains the warnings and hints flags.
I'm trying to compile a project and I'm getting this error.
The error occurs in a RemObjects source file, but I think it doesn't have anything to do with RemObjects.
Anyway this error is too generic, and I don't quite get why it happens, so how can I solve it?
The problem was that we translated the unit SysConsts and the Interface changed, removing that unit solved the problem.
This error occurs if you mix libraries. You are probably using a (third-party) library that is compiled with a different version. Try to get the latest version, or recompile if you have the source.
If the problem persists, try to get a minimal subset of the project to find the offending unit / dcu file.