- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Informe de contenido inapropiado
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.
....
- Etiquetas:
- Intel® Fortran Compiler
Enlace copiado
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Informe de contenido inapropiado
Correction: !$DIR (as originally posted) should be !DIR$ is the example. I corrected it.
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Informe de contenido inapropiado
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.
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Informe de contenido inapropiado
!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
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Informe de contenido inapropiado
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.
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Informe de contenido inapropiado
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.
- Suscribirse a un feed RSS
- Marcar tema como nuevo
- Marcar tema como leído
- Flotar este Tema para el usuario actual
- Favorito
- Suscribir
- Página de impresión sencilla