生成编译器定义的预处理器宏列表
生成由编译器定义的预处理器宏列表
gcc -E -dM - < /dev/null
使用gcc和gfortran,我可以分别使用(编辑以反映ouah的答案)和
gfortran -cpp -E -dM /dev/null
(至少在Linux上)
。如何使用英特尔编译器 icc 和 ifort 执行相同操作?我知道对于 ifort,这些宏是定义的 此处,但我希望能够自己生成此列表,因为使用的确切宏及其值将取决于关于使用的编译器选项。我还知道 predef 项目。
With gcc and gfortran I can generate a list of preprossesor macros defined by the compiler using (edited to reflect ouah's answer)
gcc -E -dM - < /dev/null
and
gfortran -cpp -E -dM /dev/null
respectively (on Linux at least).
How can I do the same with the Intel compilers icc and ifort? I know that for ifort these macros are defined here, but I would like to be able to generate this list myself, since the exact macros in use and their values will depend on the compiler options used. I am also aware of the predef project.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
与 Intel 编译器一起使用:
请注意,对于
gcc
,如果您想使用-dM
预处理器选项,还需要-E
选项。Use this with the Intel compiler:
Note that with
gcc
, the-E
option is also required if you want to use the-dM
preprocessor option.对于英特尔 Fortran 编译器 ifort,可以使用以下内容:
ifort 似乎没有像 icc、gfortran 和 gcc 那样的等效
-dM
标志。With the Intel Fortran compiler, ifort, the following can be used:
It seems than ifort does not have an equivalent
-dM
flag like icc, gfortran and gcc do.对于 gfortran,请注意 gfortran -E -dM -
/dev/null
产生与调用gcc
相同的结果,这可能没有帮助。您可能想要这样的东西(源):gfortran -cpp -E -dMempty.f
这将为您提供
gfortran
实际预定义内容的较小列表。您会注意到,结果很可能不包含任何有助于确定操作系统的信息。一般来说,对于 Fortran,您需要自己定义它们。请参阅此处了解更多详细信息。您也可以尝试类似的方法,但我对该解决方案的实用性有点怀疑。此外,该链接还意味着gfortran
曾经定义的内容比现在多。For
gfortran
, beware thatgfortran -E -dM - < /dev/null
yields the same result as if you had calledgcc
, which probably isn't helpful. You probably want something like this (source):gfortran -cpp -E -dM empty.f
That will give you a smaller list of what
gfortran
actually predefines. You will note that the results most likely do not include anything helpful for determining the operating system. Generally, for Fortran, you're left to define those yourself. See here for additional detail. You could also try something like this, but I'm a little skeptical of the practically of that solution. Also, that link implies that at one timegfortran
defined more than it does now.