View previous topic :: View next topic |
Author |
Message |
wahorger
Joined: 13 Oct 2014 Posts: 1217 Location: Morrison, CO, USA
|
Posted: Thu Jul 21, 2016 9:57 pm Post subject: Struggling with conditional compilation |
|
|
I have a parameter set that IO want to include with every INCLUDE'd file. Borrowing from "C", I have coded the parameter file (parameters.ins) to look like this:
Code: |
#ifndef parameters_already_included
#define parameters_already_included
.
.
integer,parameter::abcd=0
.
.
#endif
|
At the start of every other included file is:
Code: |
include 'parameters.ins'
|
Within the main modules are INCLUDE sequences like this:
Code: |
include 'abcd.ins'
include 'defg.ins'
|
Both abcd.ins and defg.ins have the parameter.ins file included. Logically, the parameter.ins file is included when abcd.ins is itself included (the variable parameters_already_included does not exist), then when defg.ins is included, the body of the parameters.ins file will not be compiled because the variable parameters_already_included does now exist.
What appears to be happening is that the condtionals are failing to properly execute, causing each parameter statement to be flagged as an error (duplicate definition).
Anyone else having this as an issue? |
|
Back to top |
|
|
mecej4
Joined: 31 Oct 2006 Posts: 1886
|
Posted: Fri Jul 22, 2016 1:22 am Post subject: |
|
|
You need to use the /CFPp option in order to preprocess C style directives. |
|
Back to top |
|
|
wahorger
Joined: 13 Oct 2014 Posts: 1217 Location: Morrison, CO, USA
|
Posted: Fri Jul 22, 2016 1:32 am Post subject: |
|
|
Yes, and that is on the command line. |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7924 Location: Salford, UK
|
Posted: Fri Jul 22, 2016 8:00 pm Post subject: |
|
|
I tried a simple test and it worked OK so it probably depends on how this is put together. One thing to bear in mind is that FTN95 will not open a second copy of a particular INCLUDE file. It will use the existing copy that has been kept open. |
|
Back to top |
|
|
wahorger
Joined: 13 Oct 2014 Posts: 1217 Location: Morrison, CO, USA
|
Posted: Sat Jul 23, 2016 7:35 pm Post subject: |
|
|
If I understand, then the conditionals that would be processed inside of an INCLUDE'ed file would already be "resolved", there being only a single copy opened and processed. With that assumption, then the #ifndef would always be resolved as TRUE, and the remainder of the INCLUDE'ed file would always be processed.
I may have the terminology wrong, but I think this is referred to a single pass include processor. This may be to trying to use SCC to build the freetype library several months ago.
Ah, well. I'll deal with it a different way! |
|
Back to top |
|
|
|