[英]User-defined errors with nagfor preprocessor
I'm trying to abort compilation if an unsupported fortran compiler is used. 如果使用不受支持的fortran编译器,我正试图中止编译。 The nagfor preprocessor defines the macro
NAGFOR
, so I wrote the following test program: nagfor预处理器定义宏
NAGFOR
,所以我编写了以下测试程序:
program foo
implicit none
#ifdef NAGFOR
PRINT *, "Hello from nagfor"
#else
#error "Compiler not supported"
#endif
end program foo
When I compile with gfortran or ifort, I get the expected error message 当我使用gfortran或ifort编译时,我收到了预期的错误消息
$ gfortran foo.F90
foo.F90:8:2: error: #error "Compiler not supported"
$ ifort foo.F90
foo.F90(8): #error: "Compiler not supported"
but nagfor gives a different error 但是nagfor给出了不同的错误
$ nagfor foo.F90
NAG Fortran Compiler Release 5.3.1(907)
"foo.F90", line 8: error: unknown fpp directive.
I can't find any mention of how to create an error in the nagfor fpp documentation so maybe #error
doesn't exist. 我找不到如何在nagfor fpp文档中创建错误,所以也许
#error
不存在。 In which case, is there an alternative approach to get the same effect? 在哪种情况下,是否有另一种方法可以获得相同的效果?
I work on the NAG Compiler. 我在NAG编译器上工作。 fpp is intended to be pretty lightweight in terms of operation (and functionality).
fpp在操作(和功能)方面非常轻量级。 It originates from Sun;
它起源于太阳; we are using a version based on the netlib one from http://netlib.org/fortran/fdfpp.tgz .
我们正在使用http://netlib.org/fortran/fdfpp.tgz中基于netlib的版本。
The fpp manual ( http://www.nag.co.uk/nagware/np/r60_doc/fpp.html ) does not document #error
as being supported, which you have discovered. fpp手册( http://www.nag.co.uk/nagware/np/r60_doc/fpp.html )没有将
#error
为您所发现的支持。
As francescalus suggests, the best way to acheive what you want would be with something along the lines of 正如francescalus所说,实现你想要的东西的最好方法就是用一些东西
program foo
implicit none
#ifdef NAGFOR
PRINT *, "Hello from nagfor"
#else
error "Compiler not supported"
#endif
end program foo
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.