问题描述
我已经看过并使用了如下的C ++代码:
I have seen and used C++ code like the following:
int myFourcc = 'ABCD';
它适用于最近的GCC版本,不知道最新版本。
标准中的这个功能吗?
它叫什么?
It works in recent versions of GCC, not sure how recent.Is this feature in the standard?What is it called?
我在搜索网络时遇到了麻烦...
I have had trouble searching the web for it...
EDIT:
我还为以后的观察者找到了此信息:
I found this info as well, for future observers:
从
例如,'ab'对于具有8位字符的目标,将被解释为(int)((unsigned char)'a'* 256 +(unsigned char)'b')'和'\234a'
(int)((unsigned char)'\234'* 256 +(unsigned char)'a')'。
For example, 'ab' for a target with an 8-bit char would be interpreted as (int) ((unsigned char) 'a' * 256 + (unsigned char) 'b')', and '\234a' as
(int) ((unsigned char) '\234' * 256 + (unsigned char) 'a')'.
推荐答案
请注意,根据C标准,字符常量,但是包含多个字符的字符常量的值是实现定义的。最新版本的GCC提供支持多字节字符常量,而不是错误警告多字符字符常量或警告:字符常数太长的类型。
"Note that according to the C standard there is no limit on the length of a character constant, but the value of a character constant that contains more than one character is implementation-defined. Recent versions of GCC provide support multi-byte character constants, and instead of an error the warnings multiple-character character constant or warning: character constant too long for its type are generated in this case."
这篇关于是int x ='fooo'编译器扩展吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!