dan*_*opa 3 c++ compilation c++17
现代Fortran提供了一些跨平台机制来记录用于构建应用程序的编译器版本和设置.C++ 17有哪些方法可以捕获这些信息?Horton和Van Weert的着作,Beginning C++ 17,似乎没有解决这个问题.
Fortran工具在下面进行了调查.
在iso_fortran_envFortran中提供一种标准方法来访问用于编译代码的编译器版本和设置.随后是一个示例代码段.
program check_compiler
use, intrinsic :: iso_fortran_env, only : compiler_options, compiler_version
implicit none
write ( *, 100 ) "compiler version = ", compiler_version ()
write ( *, 100 ) "compiler options = ", trim ( compiler_options () )
100 format ( A, A, / )
stop "normal termination . . ."
end program check_compiler
Run Code Online (Sandbox Code Playgroud)
$ gfortran -o check_compiler check_compiler.f08
$ ./check_compiler
compiler version = GCC version 8.0.0 20170604 (experimental)
compiler options = -fPIC -mmacosx-version-min=10.12.7 -mtune=core2
STOP normal termination . . .
Run Code Online (Sandbox Code Playgroud)
Fortran命令喜欢execute_command_line,get_command并get_environment_variable提供另一种在编译时记录信息的路径.
C++ 17有哪些方法可以捕获这些信息?
没有.C++标准甚至不承认"编译器"或"选项"的概念; 只有"实施".
此外,它实际上没有意义,因为链接到同一程序的不同C++文件可以使用不同的选项进行编译.而且我不只是在谈论DLL/SO; 理论上,您可以静态链接使用不同选项甚至不同编译器版本编译的文件.
不同的编译器有办法通过宏指定它们的版本.但每个人都有自己的报道方式.
| 归档时间: |
|
| 查看次数: |
146 次 |
| 最近记录: |