Inline keyword gfortran

老子叫甜甜 提交于 2019-12-08 18:48:35

问题


Is there any Fortran keyword equivalent to the C "inline" keyword?

If some compiler-specific keyword exist, is there any for gfortran?


回答1:


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 CONTAINed subprogram are more aggressively inlined by gfortran, but that may or may not help.




回答2:


There is no source code statement I know of. Sometimes you can use statement functions, which are obviously inlined. Otherwise use compiler comand line options as gfortran's "-finline-functions".



来源:https://stackoverflow.com/questions/6763402/inline-keyword-gfortran

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!