Quantcast
Channel: Intel® Fortran Compiler
Viewing all articles
Browse latest Browse all 3270

ifort-14.0 -cpp not referentially transparent

$
0
0
$ 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.

 


Viewing all articles
Browse latest Browse all 3270

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>