!DEC$ DEFINE

!DEC$ DEFINE

I want to make som special handing for each function in debug mode.
So I found the !DEC$ DEFINE,

I want to do that in each subroutine of my programm.
So I don't want to make a Flag like,

if (debug) then
dump (variables)
edif

sice I need that only in debug mode, an I want to minimize computational costs.
The problem of the !DEC$ DEFINE is that is only local. I want to make a global flag debug. If the flag is set, the compiler should make the code, with all debug-handling, and the simple code if I dont set this debug flag.

I could define "!DEC$ DEFINE DEBUG" in each source file, but, then it's tedious to swicht the flag on or of for all files.

Is there any posibility to make such a global flag, in the !DEC% DEFINE mode ?

4 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.
Best Reply

Typically the way this is handled is to add a _DEBUG symbol name in the Project > Fortran > Preprocessor property page for the Debug configuration. You can then test this with !DEC$ IF DEFINED (_DEBUG) in your source. Read the documentation on preprocessing for more details. Note that if you use the !DEC$ style, you don't have to explicitly enable preprocessing as these are handled directly by the compiler.

Steve

Quoting - Steve Lionel (Intel)
Typically the way this is handled is to add a _DEBUG symbol name in the Project > Fortran > Preprocessor property page for the Debug configuration. You can then test this with !DEC$ IF DEFINED (_DEBUG) in your source. Read the documentation on preprocessing for more details. Note that if you use the !DEC$ style, you don't have to explicitly enable preprocessing as these are handled directly by the compiler.

I find it real handy to set the option to compile lines of code with a D in column 1 for debug but not for release.
Fast and easy!

Regards,
Erik

Well, ok, but that only works for fixed-form source.

Steve

Login to leave a comment.