forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Conditional compilation

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
Anonymous
Guest





PostPosted: Sun Aug 20, 2006 1:37 am    Post subject: Conditional compilation Reply with quote

Hello,

Can somebody please help me with the following simplified piece of code?

PROGRAM TEST
IMPLICIT NONE

#define x

#ifdef x
PRINT*, 'ifdef works...'
#endif

#ifndef x
PRINT*, 'ifndef works...'
#endif

STOP
END PROGRAM TEST


It's the first time I'm trying to do something with preprosessor options and it doesn't work.
I'm compiling the program with "FTN95 TEST.F95 /CFPP" on the command line, with no errors, but on execution of the program NOTHING is printed to the screen.

So, I'm wondering was I'm doing wrong.

Kind regards
Back to top
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7927
Location: Salford, UK

PostPosted: Mon Aug 21, 2006 1:18 am    Post subject: Conditional compilation Reply with quote

Lucas

The #define and #ifdef work OK for me but #ifndef and the associated code is ignored.
At first sight there is something wrong with #ifndef. If it is not implemented by FTN95 then an error should be flagged.

I do not think that the outcome will depend on the version number of FTN95 because the feature was only added at about version 4.8 and to my knowledge there have been no changes made.

Are you sure you are not getting the first PRINT statement? Have you tried running from a DOS box?

The more common usage is to provide a value for the "SPECIAL PARAMETER" via the FTN95 command line so you may get better results this way.
Back to top
View user's profile Send private message AIM Address
Anonymous
Guest





PostPosted: Mon Aug 21, 2006 3:02 am    Post subject: Conditional compilation Reply with quote

Paul,

Thanks for your reply, I am a step further now.
This time I tried the following code:

PROGRAM TEST
IMPLICIT NONE
INTEGER :: I = 0
#define x
#ifdef x
I = 1
#endif
#ifndef x
I = 2
#endif
WRITE(6,*) I
END PROGRAM

and ran it from a DOS-box. The result was 2.
I did expect a 1 however, so now is my question: where can I find more detailed info about compiler directives such as #define, #ifdef and #ifndef,...? Because the help file doesn't tell me that much in this case.

Regards, Lucas.
Back to top
Anonymous
Guest





PostPosted: Mon Aug 21, 2006 4:27 am    Post subject: Conditional compilation Reply with quote

Addendum:

I had better tried this first before posting:

PROGRAM TEST
IMPLICIT NONE
INTEGER :: I = 0

#define x

#ifdef x
I = 1
WRITE(6,*) I
#endif

#ifndef x
I = 2
WRITE(6,*) I
#endif

END PROGRAM

The resulting output is
1
2

So it seems that the "variable" x is at the time defined and undefined?
Very strange.
Back to top
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7927
Location: Salford, UK

PostPosted: Mon Aug 21, 2006 5:31 am    Post subject: Conditional compilation Reply with quote

Lucas

As I tried to say, #ifndef does not appear to be implemented in FTN95 and FTN95 should give an error report when an attempt is made to use #ifndef.

Avoid using #ifndef.
Back to top
View user's profile Send private message AIM Address
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7927
Location: Salford, UK

PostPosted: Tue Aug 22, 2006 9:54 am    Post subject: Conditional compilation Reply with quote

Lucas

#ifndef has now been fixed for the next release of FTN95.
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group