Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Preprocess included file

Gerald_Duff
Beginner
723 Views

Hi,

Is it possible to preprocess included files ? By default, it seems to me that they are not.


Regards,

Gerald

 

0 Kudos
8 Replies
Steven_L_Intel1
Employee
723 Views
If you want include files preprocessed, use #include to include them.
0 Kudos
jimdempseyatthecove
Honored Contributor III
723 Views
I use #include "filename.inc" in my programs with FPP precompilation.

Note....

Your #include file may contain #define's for macros and macro substitution

*** #include macros are "in scope" from the #include through the end of the compilation unit (or until explicitly #undef'd)

The macros (if used) are not scoped to the subroutine/function as are the FORTRAN include files (no #)

Jim Dempsey
0 Kudos
Gerald_Duff
Beginner
723 Views
Thanks for the prompt answer, this solves my issues. It also raises another question : to make "#include" work I had to add the absolute path to the included file in the pre-processor option, whereas "include" was directly looking into the source folder.


In which way the include directories are different between "#include" and "include" ?

Regards
0 Kudos
Steven_L_Intel1
Employee
723 Views
Gerald, this is a known bug, issue DPD200151471, not yet fixed. Please add the folder containing the include files as an "additional include directory" as a workaround.
0 Kudos
jimdempseyatthecove
Honored Contributor III
723 Views
>>to make "#include" work I had to add the absolute path to the included file in the pre-processor option

??? I am using relative paths ???

Preprocsssor | Additional Include Directories

... (other include directories here
..\..\Source\Modules
...


The path is relative to the folder containing the project file

In the .f90 files I then use

#include "DEF_ALL.INC"

Where the above is one of my FPP include files

Jim Dempsey
0 Kudos
Gerald_Duff
Beginner
723 Views
Thanks, this works indeed. However, it is annoying to have to add an additional include directory each time a file is included (especially when the included file is in the same folder than the source!).

Regards,

Gerald
0 Kudos
jimdempseyatthecove
Honored Contributor III
723 Views
This is a Visual Studio issue. If when creating a project you specify that you do not wish to make seperate folder for project (which is a misnomer since it means folder for "project source files" as opposed to "project file" then you likely will not need to specify the folder where your include files reside. Or conversely you can place your FPP include files in your project folder.

The way I use FORTRAN is to isolate my module files in a seperate folder from the subroutines and functions that use the module. This folder is required to be placed in the include path. I place my FPP include files in this folder.

Jim Dempsey
0 Kudos
Anonymous66
Valued Contributor I
723 Views

A fix has been found for this issue. We are currently planning to include it in the next major release which is currently scheduled for later this year.

Annalee

0 Kudos
Reply