是否有任何与QUOT;移动目标"海湾合作委员会或锵`-std =别名值',暗示[使用最新的标准和QUOT ;? [英] Are there any "moving target" alias-values for GCC or Clang `-std=`, implying "use the latest standard"?

查看:116
本文介绍了是否有任何与QUOT;移动目标"海湾合作委员会或锵`-std =别名值',暗示[使用最新的标准和QUOT ;?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个将始终使用由 GCC / G ++支持C / C ++标准的最新版本的shell别名 / / 铛++ (一个别名为C,有一个别名为C ++)。我知道这可能有多个跨pretations:

I'd like to create shell aliases that will always use the "latest" version of the C/C++ standards supported by gcc/g++/clang/clang++ (one alias for C, one alias for C++). I realize that this could have multiple interpretations:


  • 最新的GNU扩展的标准

  • 最新发布的标准(例如C ++ 14)

  • 最新的未发行的标准(例如C ++ 1Z)

  • 由编译器全面实施最新的标准(例如C ++ 11 GCC 4.9,C为GCC 5 + ++ 14)

  • ...可能还有其他的选择我都没有想到

....但这些外壳别名的目的,我不在乎那么多的移动只要我知道上述规则是用来值用于确定所使用的标准模式。

....but for the purpose of these shell aliases, I don't care that much which "moving" value is used as long as I know which of the above rules is used to determine which standard-mode is used.

无论是编译器包括一个参数,别名,跟踪一个移动的最新标准?我不明白的别名选项提及任何在海湾合作委员会的文档(尽管我的谷歌福可以简单地失败我);同时,锵用户手册提到,对于C支持的模式[明确STD模式...],并为那些模式不同的化名,但我没有看到那里的别名本身记录。

Does either compiler include an argument-alias that tracks a moving "latest standard"? I don't see any mention of alias-options in the GCC docs (though my google-fu may simply be failing me); meanwhile, the Clang user manual mentions that "The supported modes for C are [explicit std modes...] and various aliases for those modes", but I don't see where the aliases themselves are documented.

推荐答案

有在任何你所提到的编译器没有这个选项。

There is no such option in any of the compilers you mention.

然而,这是很容易创建一个简单的Makefile的沙箱,其中包括适当的设置。我用的是这样的:

However, it is easy enough to create a simple Makefile for a sandbox which includes appropriate settings. I use something like this:

CFLAGS = -Wall -std=c11 -D_XOPEN_SOURCE_=700
CXXFLAGS = -Wall -std=c++14 -D_XOPEN_SOURCE_=700

在默认的编译完成的我需要休息,所以没有必要填写的名字和所有源文件的依赖生成文件,前提是我一直在沙箱单文件的可执行文件。

The default build rules accomplish the rest of my needs, so there is no need to fill in the makefile with the names and dependencies of all the source files, providing that I'm always sandboxing a single-file executable.

就这样,我可以只输入使富编译任 foo.c的 foo.cc 。 (或使foo.o的如果我不想要一个链接。)的功能测试宏设置为我节省不必记住要做到这一点,我的源文件以及

With that, I can just type make foo to compile either foo.c or foo.cc. (Or make foo.o if I don't want a link.) The feature test macro setting saves me having to remember to do that in my source files as well.

和编译使用非默认的编译器:使富CXX =铛++ 。这比打字更不是铛++ -Wall -o富foo.cc

And to compile with the non-default compiler: make foo CXX=clang++. That's still less typing than clang++ -Wall -o foo foo.cc

(其实我用的是比这更复杂一点。它包括 .S 后缀规则,一些变量来简化设置优化和调试选项。但其原理是相同的。)

(Actually the one I use is a bit more sophisticated than that. It includes a suffix rule for .S and some variables to simplify setting optimization and debugging options. But the principle is the same.)

这篇关于是否有任何与QUOT;移动目标"海湾合作委员会或锵`-std =别名值',暗示[使用最新的标准和QUOT ;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆