- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
$ cat macro.F90 #define X_LT(a) (a < 3) #define X_GE(a) (!X_LT(a)) #if !X_LT(3) #warning no problem here #endif #if X_GE(3) #warning "syntax error" with ifort, not with gfortran #endif $ ifort -c macro.F90 macro.F90(5): #warning: no problem here macro.F90(8): #error: #if: syntax error. macro.F90(9): #warning: "syntax error" with ifort, not with gfortran
I do not think this is useful preprocessor behavior. This came up in a version check macro shared between C and Fortran. Changing to #define X_GE(a) (0 == X_LT(a)) is a workaround.
Intel(R) Fortran Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 14.0.0.080 Build 20130728
Copyright (C) 1985-2013 Intel Corporation. All rights reserved.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If I may double-check my understanding please..
The actual problem that you are having is the syntax error on the line " #if X_GE(3) ", and the other messages are fine.
The exclamation point is a Fortran comment character.
The Fortran preprocessor (despite its similarity to the C preprocessor) will treat the exclamation point as a comment delimiter, which does funny things to the macro expansion for your macro X_GE
You can pass an option to the Fortran preprocessor (fpp) to ignore the exclamation point, as:
ifort -Qoption,fpp,-f_com=no myfile.F
--Lorri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, Lorri
Thank you for anwering this.
But how does it explain Line 05 works fine? I verified gfortran will not report an error in this case.
Thanks,
Yolanda
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The other warnings are just to show which lines have been reached. My concern is that '!' is being interpreted as a comment character inconsistently. It should either always be a comment or never be a comment. I would prefer never so that logical expressions can be written more naturally, but consistency is most important.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Yolanda -
I think it is as JedB. suggested ... inconsistent behavior in fpp between the processing of the #define and the processing of the #if.
--Lorri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page