- detect at compile-time that madExcept is enabled in RAD
-
- Posts: 14
- Joined: Sun Dec 28, 2014 12:30 pm
- detect at compile-time that madExcept is enabled in RAD
I test madExcept (non-commercial licence) with Delphi XE7.
According to
http://stackoverflow.com/questions/1442 ... pplication,
I supposed that checking (resp. unchecking) of "enable madExcept" in RAD Studio madExcept setings dialog (accessible with the menu item "Project / madExcept settings") enables (resp. disables) the compilation directive {$DEFINE madExcept} for all consecutive compilations. But the following two test seem not to confirm that supposition.
First test
1. The first item in the "uses" clause of my project is:
{$IFDEF DEBUG}
madExcept,
{$ENDIF }
2. In Rad Studio I check the box "enable madExcept".
3. I rebuild MyProject.
4. I run MyProject.
5. I exit MyProject.
6. Leaks report appears with a single leak.
Second test
1. I modify the first item in the "uses" clause of my project to:
{$IFDEF DEBUG}
{$IFDEF madExcept}
madExcept,
{$ENDIF }
{$ENDIF }
2. In Rad Studio I leave the box "enable madExcept" checked
3. I rebuild MyProject.
4. I run MyProject.
5. I exit MyProject.
6. No leak report is shown. This suggests that the compiler directive madExcept wasn't defined.
Questions:
1. Do you agree with results of my 2 tests?
2. Does "enable madExcept" checkbox toggles any compiler directive definition?
With kind regards,
JK
According to
http://stackoverflow.com/questions/1442 ... pplication,
I supposed that checking (resp. unchecking) of "enable madExcept" in RAD Studio madExcept setings dialog (accessible with the menu item "Project / madExcept settings") enables (resp. disables) the compilation directive {$DEFINE madExcept} for all consecutive compilations. But the following two test seem not to confirm that supposition.
First test
1. The first item in the "uses" clause of my project is:
{$IFDEF DEBUG}
madExcept,
{$ENDIF }
2. In Rad Studio I check the box "enable madExcept".
3. I rebuild MyProject.
4. I run MyProject.
5. I exit MyProject.
6. Leaks report appears with a single leak.
Second test
1. I modify the first item in the "uses" clause of my project to:
{$IFDEF DEBUG}
{$IFDEF madExcept}
madExcept,
{$ENDIF }
{$ENDIF }
2. In Rad Studio I leave the box "enable madExcept" checked
3. I rebuild MyProject.
4. I run MyProject.
5. I exit MyProject.
6. No leak report is shown. This suggests that the compiler directive madExcept wasn't defined.
Questions:
1. Do you agree with results of my 2 tests?
2. Does "enable madExcept" checkbox toggles any compiler directive definition?
With kind regards,
JK
Re: - detect at compile-time that madExcept is enabled in RA
The "madExcept" compiler directive is supposed to be set/removed automatically if you activate/deactivate madExcept.
I've just tested this with XE7, and it *does* work. However, it's somewhat "delayed". Meaning, after you have enabled/disabled madExcept you may need to change the source code (just add a space and delete it again) to force Delphi to compile, maybe once or twice, and then it should work. In newer Delphi versions the IDE APIs to force the IDE to recompile don't always work reliably. So that's why the compiler directive sometimes need a recompile or two to become effective.
I've just tested this with XE7, and it *does* work. However, it's somewhat "delayed". Meaning, after you have enabled/disabled madExcept you may need to change the source code (just add a space and delete it again) to force Delphi to compile, maybe once or twice, and then it should work. In newer Delphi versions the IDE APIs to force the IDE to recompile don't always work reliably. So that's why the compiler directive sometimes need a recompile or two to become effective.
-
- Posts: 14
- Joined: Sun Dec 28, 2014 12:30 pm
Re: - detect at compile-time that madExcept is enabled in RA
I'm sorry but it does *not* work for me.
1. While testing, I never compile but rebuild the project.
2. After madExcept enabling in RAD Studio, the XML file MyProject.dproj has no modificatios of <DCC_Define> nodes, shouldn't it? If it isn't confidential, how does the compiler directive enabling is designed.
1. While testing, I never compile but rebuild the project.
2. After madExcept enabling in RAD Studio, the XML file MyProject.dproj has no modificatios of <DCC_Define> nodes, shouldn't it? If it isn't confidential, how does the compiler directive enabling is designed.
Re: - detect at compile-time that madExcept is enabled in RA
I've tested like this:
1) Created an empty new project in XE7.
2) Added Button1 and an Button1Click event as shown in the attached screenshot.
3) Now I enable or disable madExcept, and then "build" the project.
4) The project options show that the "madExcept" conditional define is correctly set and removed (see bold text in the screenshot).
5) "Building" the project lets the blue dots in the editor jump from enabled/disabled as expected.
Could you please do the same test as above? It should produce the same results on your PC. If it doesn't something is strange/wrong...
1) Created an empty new project in XE7.
2) Added Button1 and an Button1Click event as shown in the attached screenshot.
3) Now I enable or disable madExcept, and then "build" the project.
4) The project options show that the "madExcept" conditional define is correctly set and removed (see bold text in the screenshot).
5) "Building" the project lets the blue dots in the editor jump from enabled/disabled as expected.
Could you please do the same test as above? It should produce the same results on your PC. If it doesn't something is strange/wrong...
- Attachments
-
- XE7test.png (144.23 KiB) Viewed 12644 times
-
- Posts: 14
- Joined: Sun Dec 28, 2014 12:30 pm
Re: - detect at compile-time that madExcept is enabled in RA
I did a test which is closer to the faulty context, i.e. compilation. Namely, I let compiler tell me directly whether, once at the faulty spot, it is aware of {$DEFINE madExcep} or not.
As compiler shows below (stopping in the red line), it isn't aware of the directive madExcept.
This corroborates with the fact that, contrary to your screen copy of Project Options, MyProject's "Project Options / Delphi Compiler / Conditional Defines" contains no madExcept "injection" resulting from madExcept enabling in RAD Studio.
Do you (i.e. madExcept) do that injection yourself? If "yes" then we can try to find out why madExcept doesn't recognize where the injection should be done.
MyProject wasn't written from scratch in XE7 but in D5 and then upgraded to XE7. Maybe, the upgrade wasn't perfect. But ignoring details of the injection process, I can't guess why the injection failed.
As compiler shows below (stopping in the red line), it isn't aware of the directive madExcept.
This corroborates with the fact that, contrary to your screen copy of Project Options, MyProject's "Project Options / Delphi Compiler / Conditional Defines" contains no madExcept "injection" resulting from madExcept enabling in RAD Studio.
Do you (i.e. madExcept) do that injection yourself? If "yes" then we can try to find out why madExcept doesn't recognize where the injection should be done.
MyProject wasn't written from scratch in XE7 but in D5 and then upgraded to XE7. Maybe, the upgrade wasn't perfect. But ignoring details of the injection process, I can't guess why the injection failed.
Re: - detect at compile-time that madExcept is enabled in RA
I'm not sure where it goes wrong. The madExcept IDE wizard changes the compiler directive by using the official IDE API "IOTAProject.ProjectOptions.Values['Defines']". And the adjustment is done at multiple places, once during saving the project, once before compiling and once after changing the settings dialog.
Does madExcept add the madExcept unit to your project's uses clause, if you enable madExcept, and remove it again automatically, when you disable madExcept?
I'd like to ask you again to test this with a test project instead of your main project. I understand that your real project is your main concern. But testing with a brand new test project should allow us to double check that the general concept is working at all with your installation or not. If it's working in the test project but not in your real project then we need to figure out what's different about your real project.
Does madExcept add the madExcept unit to your project's uses clause, if you enable madExcept, and remove it again automatically, when you disable madExcept?
I'd like to ask you again to test this with a test project instead of your main project. I understand that your real project is your main concern. But testing with a brand new test project should allow us to double check that the general concept is working at all with your installation or not. If it's working in the test project but not in your real project then we need to figure out what's different about your real project.
-
- Posts: 14
- Joined: Sun Dec 28, 2014 12:30 pm
Re: - detect at compile-time that madExcept is enabled in RA
No, at least because I have written it there myself according to my understanding of the madExcept documentation. I used to "comment" it and "decomment" manually during my first experience (last December) with madExcept.Does madExcept add the madExcept unit to your project's uses clause, if you enable madExcept, and remove it again automatically, when you disable madExcept?
My last screen copy shows the first items in uses clause of MyProject.
I strongly disapprove Delphi attitude concerning programmer's exclusive right to decide who beside him can modify his code. I don't ask anybody to maintain my code but I am very grateful when Delphi provides me with appropriate means (e.g. compiler directives as madExcept) which facilitate the maintenance done myself.
I've followed your pertinent advice to implement the One-Button test; pertinent because it permits to check to what extend my environment is compatible with the madExcept enabling mechanism.
The test does not work; madExcept isn't injected neither as unit name into project's "uses" clause nor as compiler directive into project options.
The attached madX.zip permits to compare my test with the yours.
Kind regards,
JK
- Attachments
-
- madX.zip
- my one-button project
- (58.57 KiB) Downloaded 275 times
Re: - detect at compile-time that madExcept is enabled in RA
Hello again,
and I'm sorry for the very late reply.
I've now tested your test project with my XE7 installation, and it works just fine for me. If I disable madExcept and then "rebuild" the project, it properly shows "disabled". If I then enable madExcept and "rebuild", if properly shows "enabled" etc. However, I always have to "rebuild", just compiling doesn't work immediately.
and I'm sorry for the very late reply.
I've now tested your test project with my XE7 installation, and it works just fine for me. If I disable madExcept and then "rebuild" the project, it properly shows "disabled". If I then enable madExcept and "rebuild", if properly shows "enabled" etc. However, I always have to "rebuild", just compiling doesn't work immediately.
Re: - detect at compile-time that madExcept is enabled in RA
Of course, the person having the problem DOES have the MadExcept IDE wizard present in the IDE menus? I have never had this problem, it works fine for me.
Warren
Warren
Re: - detect at compile-time that madExcept is enabled in RA
Also, I got no complaints about this specific problem from anybody else yet. Not sure about how many people are using the "madExcept" define, though.