ANSI C 有(或使用)哪些最常见的扩展?
您可以放置一个指向比较矩阵或可用于主编译器的扩展列表的链接。如果这些都不可用,您可以在您最喜欢的编译器中编写您使用或喜欢的扩展列表。
You can put a link to comparison matrix or lists of extensions available to main compilers. If none of this is available, you could write a list of extension you use or like in your favorite compiler.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
http://gcc.gnu.org/onlinedocs/gcc/ C-Extensions.html#C-Extensions
http://gcc.gnu.org/c99status .html
http://publib.boulder.ibm.com/infocenter/comphelp/v8v101/index.jsp?topic=/com.ibm.xlcpp8a.doc/language/ref/gcc_cext.htm< /a>
http://publib.boulder.ibm.com/infocenter/comphelp/v8v101/index.jsp?topic=/com.ibm.xlcpp8a.doc/language/ref/c99_cext.htm
http://gcc.gnu.org/onlinedocs/gcc/C-Extensions.html#C-Extensions
http://gcc.gnu.org/c99status.html
http://publib.boulder.ibm.com/infocenter/comphelp/v8v101/index.jsp?topic=/com.ibm.xlcpp8a.doc/language/ref/gcc_cext.htm
http://publib.boulder.ibm.com/infocenter/comphelp/v8v101/index.jsp?topic=/com.ibm.xlcpp8a.doc/language/ref/c99_cext.htm
到目前为止 C++/ISO-C 风格的注释: //
C++/ISO-C style comments by far: //
嗯,这取决于当您说“ANSI C”时您指的是 C89 还是 C99。由于大多数主流实现尚未完全兼容 C99,因此我将假设 C89。
在这种情况下,我会说(不包括 POSIX 或 BSD 套接字等特定 API):
long long
必须是最常见的扩展;union
成员;inline
可能就在那里;snprintf
在很多地方都可用;alloca
编辑: 啊,是的,我怎么会忘记无处不在的
//
风格注释。Well, this depends on whether you mean C89 or C99 when you say "ANSI C". Since most mainstream implementations aren't fully C99-compliant yet, I'm going to assume C89.
In that case, I'd say (and not including specific APIs like POSIX or BSD Sockets):
long long
must be the most common extension;union
members other than the last written;inline
is probably up there;snprintf
is available in a lot of places;alloca
Edit: Ahh yes, how could I forget the ubiquitous
//
style comment.在臭名昭著的嵌入式 C 编译器之一中,您可以独立于处理器的偏好为结构类型指定小端或大端。如果您记得不要通过(例如)忘记字节顺序的
int*
访问其中一个字段,那么编写设备驱动程序非常方便。你认真对待特征矩阵的事情吗?你认为SO成员没有更好的事可做吗?
In one of the notorious compilers for embedded C, you can specify little- or big-endian for a struct type independently from the processor's preference. Very convenient for writing device drivers, if you remember not to access one of the fields through (say) an
int*
that forgets the endianness.Are you serious with the feature matrix thing? Do you think SO members have nothing better to do?
许多编译器允许匿名联合内的匿名结构,这对于某些事情很有用,例如:
A number of compilers allow anonymous structs inside anonymous unions, which is useful for some things, e.g.: