生成编译器定义的预处理器宏列表

发布于 2025-01-07 05:35:21 字数 596 浏览 4 评论 0原文

生成由编译器定义的预处理器宏列表

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

左秋 2025-01-14 05:35:21

与 Intel 编译器一起使用:

icc -E -dM - < /dev/null

请注意,对于 gcc,如果您想使用 -dM 预处理器选项,还需要 -E 选项。

Use this with the Intel compiler:

icc -E -dM - < /dev/null

Note that with gcc, the -E option is also required if you want to use the -dM preprocessor option.

染柒℉ 2025-01-14 05:35:21

对于英特尔 Fortran 编译器 ifort,可以使用以下内容:

ifort -E -fpp /dev/null -dryrun 2>&1 | grep -e -D | cut -c 5-

ifort 似乎没有像 icc、gfortran 和 gcc 那样的等效 -dM 标志。

With the Intel Fortran compiler, ifort, the following can be used:

ifort -E -fpp /dev/null -dryrun 2>&1 | grep -e -D | cut -c 5-

It seems than ifort does not have an equivalent -dM flag like icc, gfortran and gcc do.

猫弦 2025-01-14 05:35:21

对于 gfortran,请注意 gfortran -E -dM - /dev/null 产生与调用 gcc 相同的结果,这可能没有帮助。您可能想要这样的东西():

gfortran -cpp -E -dMempty.f

这将为您提供 gfortran 实际预定义内容的较小列表。您会注意到,结果很可能不包含任何有助于确定操作系统的信息。一般来说,对于 Fortran,您需要自己定义它们。请参阅此处了解更多详细信息。您也可以尝试类似的方法,但我对该解决方案的实用性有点怀疑。此外,该链接还意味着 gfortran 曾经定义的内容比现在多。

For gfortran, beware that gfortran -E -dM - < /dev/null yields the same result as if you had called gcc, 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 time gfortran defined more than it does now.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文