存在哪些 C GNU 主义?
我最近将一个项目从 GCC 移植到 clang(其中我修复了一些 C GNU 主义)。这让我开始思考:存在哪些 C GNU 主义(GCC 支持的 C 语言的扩展,但尚未标准化)?哪里有完整的列表?
I was recently porting a project from GCC to clang(in which I fixed a number of C GNU-isms). This got me thinking: what C GNU-isms(extensions to the C language supported in GCC, which are not standardized) exist? Is there a comprehensive list anywhere?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是直接来自 GCC 网站的相当全面的列表。好像还蛮多的,祝你筛选顺利!
http://gcc.gnu.org/onlinedocs/ gcc-4.2.0/gcc/C-Extensions.html
Here is a pretty comprehensive list straight from GCC's website. There seems to be quite a lot, so I wish you the best of luck sifting through it!
http://gcc.gnu.org/onlinedocs/gcc-4.2.0/gcc/C-Extensions.html
我发现的最好的 GNU 主义之一是在填充结构时显式的键声明。
这不允许跳过成员或对它们重新排序,如果这样做只会引发错误,但对于 100 多个元素结构,这变得非常有价值。
One of the nicest GNUisms I found was explicit key declaration while filling structures.
This does not allow to skip members or reorder them, just throws an error if you do so, but with 100+ element structures this becomes invaluable.
尽管有很多扩展,并且我尊重 Beta 的回答,但您的项目不太可能依赖其中的许多扩展。可以在 GNU 构建中禁用扩展,因此只需这样做即可提前警告您代码库中任何潜在的不兼容性。
您可能会遇到其他问题,例如 GCC 支持大多数 C99 功能,而一些流行的编译器不支持(特别是 Microsoft VC++)。因此,当您测试代码库时,您可能也想禁用 C99 功能。
Although there are many extensions, and I defer to Beta's answer for that, it is unlikely that your project relies upon many of them. It is possible to disable extensions in a GNU build, so simply doing that will give you advance warning of any potential incompatibilities in your code base.
You may encounter other problems such as the fact that GCC supports most C99 features, whereas some popular compilers do not (Microsoft VC++ specifically). So you may want to disable C99 features too when you test the code base.