- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In Windows, I have long used iFort's simple compiler directive facility for conditional compilation.
https://software.intel.com/en-us/fortran-compiler-developer-guide-and-reference-compiler-directives
for example
!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.
....
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Correction: !$DIR (as originally posted) should be !DIR$ is the example. I corrected it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
!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$...
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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:
-DFOO=-1 -DFIE=0
etc.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page