In Windows, I have long used iFort's simple compiler directive facility for conditional compilation.
!DIR$ IF(FOO==1) do something !DIR$ ELSE do something else !DIR$ ENDIF
In Windows Developer Studio the value of FOO can be set globally in the project properties page in
Configuration Properties > Fortran > Preprocessor > Preprocessor Definitions
in the form FOO=1;FIE=0;FUM=1 ... etc.
These definitions are then applied to all files in the project. Note that this does not require the "Preprocess Source File" property to be Yes.
I am now trying to get this to work in Linux where I am running Code:Blocks for Fortran (CBFortran) as the IDE. CBFortran offers a project build options page with many of the compiler options, but no "Preprocessor Definitions" line. I would appreciate some guidance on how to use Intel's Compiler Directives feature in this context.
From the compiler's perspective, this is the same as using fpp and one uses -D to define preprocessor symbols on the command line. Your question is really directed at Code:Blocks, it's not an Intel issue.
!DIR$ are vendor specific directives, otherwise are comments
You may need to make your !DIR$ directives safe for Code:Blocks
!DIR$ IF(FOO==1) iFrom = from_something iTo = to_something iStep = step_something !DIR$ ELSE iFrom = from_something_else iTo = to_something_else iStep = step_something_else !DIR$ ENDIF do i=iFrom, iTo, iStep ...
(you will also need to -DFOO... in your compiler option)
Your code may still be non-portable, at least to those compilers not supporting !DIR$...
The question was how to specify defined symbols using the Code:Blocks UI. If Code:Blocks allows additional command line options (I don't use it), you can add:
I found it and verified that it works. It was in Build Options>Compiler Settings># defines.
This tab is initially hidden in the GUI, but appears if you repeatedly click on the right arrow in the row of tabs.
Thanks to everyone who replied.