Silverfrost Forums

Welcome to our forums

Struggling with conditional compilation

21 Jul 2016 8:57 #17820

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:

#ifndef parameters_already_included
#define parameters_already_included
.
.
      integer,parameter::abcd=0
.
.
#endif

At the start of every other included file is:

        include 'parameters.ins'

Within the main modules are INCLUDE sequences like this:

        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?

22 Jul 2016 12:22 #17821

You need to use the /CFPp option in order to preprocess C style directives.

22 Jul 2016 12:32 #17822

Yes, and that is on the command line.

22 Jul 2016 7:00 #17828

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.

23 Jul 2016 6:35 #17829

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!

Please login to reply.