Inserting of mad-units into project file might fail...

delphi package - automated exception handling
Post Reply
Whookie
Posts: 7
Joined: Fri May 29, 2015 8:20 am

Inserting of mad-units into project file might fail...

Post by Whookie »

Hi!
I'm just evaluating madExcept (using Delphi XE8) and when enabling/disabling the integration into my project, I saw that your exception dialog is only displayed when compiled in debug mode. At first I thought that this might be dependant of some Linker/Compiler switches but after a little bit of investigation I found the problem in the way my project files are made:

Code: Select all

program SomeProggi;
{$I ..\..\source\switches.inc}

{$R *.dres}

uses
  {$IfNDef RELEASE} FastMM4, {$EndIf}
  Forms,
  ...  
With conditional defines I remove some units (not only FastMM4 - but for simplicity only this unit is shown) from the project. This is depending on release and debug version (but is not limited to).

Now when enabling madExcept i get:

Code: Select all

  {$IfNDef RELEASE} FastMM4, madExcept, madLinkDisAsm, madListHardware, madListProcesses, madListModules, {$EndIf}
And this is the reason why madExcept doesn't work in release-mode.

After coming up with this, I changed the code manually to:

Code: Select all

uses
  {$IfNDef RELEASE} FastMM4,  {$EndIf}
  madExcept, madLinkDisAsm, madListHardware, madListProcesses, madListModules,
  Forms,
this does work, but now if you disable madExcept again, it removes all its untis and the closing $EndIf:

Code: Select all

uses
  {$IfNDef RELEASE} FastMM4,
  Forms,
I also tried to but your units atop of my $IfNDef (thats not a good idea with FastMM4 though, but I could live with it) but when saving the project you remove them immediately and put them back inside the of the $IfNDef.

All that said, maybe there is another way to handle unit insertion?
Maybe place it behind any conditional defines (somewhere outside of them) and don't remove the $EndIf when disabling.
madshi
Site Admin
Posts: 10764
Joined: Sun Mar 21, 2004 5:25 pm

Re: Inserting of mad-units into project file might fail...

Post by madshi »

You can work around the issue like this:

1) First add the following comment above your uses clause: "// dontTouchUses <- this tells madExcept to not modify the uses clause of this file".
2) Add the units manually to the uses clause at the right location, and put them into "{$ifdef madExcept} ... {$endif}".

That should solve all problems. When you activate/deactivate madExcept, you may have to force a rebuild, though, to make sure that the "madExcept" define is properly evaluated. In the moment when you activate/deactivate madExcept, the madExcept IDE wizard tries to convince the IDE that a recompile is necessary, but the IDE doesn't always listen, sadly.
Post Reply