问题描述
是否有任何Fortran关键字等同于Cinline关键字?
如果存在某个特定于编译器的关键字,那么对于gfortran有没有用?
通常,Fortran规范授予编译器编写者在如何实现事物方面有很大的范围,因此一个语言级别的构造会迫使(甚至是在现代Fortran中通常做的不是指定优化,而是告诉编译器它可以用来决定的东西要实施什么优化。因此,一个示例是标注无副作用函数或子例程 PURE
,以便启用某些优化(实际上,这可能会使内联更容易)。 否则,正如@Vladimir F指出的那样,您可以使用 预编译的编译器选项。
类似地,gfortran似乎更加激进地嵌入了 CONTAIN
ed子程序,但这可能有帮助。 >
Is there any Fortran keyword equivalent to the C "inline" keyword?
If some compiler-specific keyword exist, is there any for gfortran?
In general, the Fortran specifications grant the compiler writers enormous scope in how to implement things, so a language-level construct that forced (or even hinted) specific optimizations would be very un-Fortran-y.
What you typically do in modern Fortran is not specify optimizations, but tell the compiler things it can use to decide what optimizations to implement. So an example is labelling a side-effect-free function or subroutine PURE
, so that certain optimizations are enabled (and actually, this may make for easier inlining).
Otherwise, as @Vladimir F points out, you can use compiler options which are presecriptive in this way.
In a similar vein, it seems that CONTAIN
ed subprogram are more aggressively inlined by gfortran, but that may or may not help.
这篇关于内联关键字gfortran的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!