MSVC13RC still not respecting C standards?
我刚刚下载了MSVC2013RC,因为听说它将比以前版本的MSVC更好地处理c标准。因此,我只是下载并测试了一些我真正在Windows平台上想要的东西。
但是第一次测试已经使我失望了很多。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | #include <stdlib.h> #include <stdbool.h> #include <stdio.h> int testFunction(int iIn); int main(int argc, char** argv) { int *TheKiddingBool; TheKiddingBool= NULL; TheKiddingBool= malloc(sizeof (int)); *TheKiddingBool= 17; _Bool bWow; bWow = true; if (testFunction(*TheKiddingBool) == bWow) { printf("\ \ QAtest succesed!\ \ "); } return 0; } int testFunction(int iIn) { return iIn; } |
这是MSVC13的C编译器中的一个很难解决的错误吗?
或者我只是了解这行
6.3.1.2 Boolean type
§1 When any scalar value is converted to _Bool, the result is 0 if the value compares equal
to 0; otherwise, the result is 1.
c99 ISO / IEC 9899:TC3的
完全错误吗?
根据7.18.3
true
扩展为整数常量1
将您的比较设为
好吧,msam指出了我
6.3.1.1 — The rank of _Bool shall be less than the rank of all other standard integer types.
然后我查明了这种"排名"的含义,我弄清楚了,这不是一个错误,我使用了错误的返回类型,因为标准规定_Bool必须具有最低的排名。
(再次感谢您的帮助)
6.3.1.1 — The rank of _Bool shall be less than the rank of all other standard integer types.
这意味着当执行算术比较时,
请注意,请考虑
6.3 Conversion of an operand value to a compatible type causes no change to the value or the
representation.
和
6.2.5 An object declared as type _Bool is large enough to store the values 0 and 1.