根据GCC website和SDCC Manual§3.5.7,GCC和SDCC都允许使用这样的二进制常量,其中十进制数2表示为:0b0010
不幸的是,splint似乎没有处理好这个问题导致解析错误,如下所示。
binaryConstants.c
#include <stdio.h>
int main(){
int one = 0b0001;
int two = 0x2;
int three = 3;
printf("B: %d\nH: %d\nD: %d\n", one, two, three);
return 0;
}
输出
$ splint binaryConstants.c
Splint 3.1.2 --- 19 Oct 2016
binaryConstants.c:3:18: Parse Error. (For help on parse errors, see splint -help
parseerrors.)
*** Cannot continue.
$
使用+ gnuextensions输出
$ splint +gnuextensions binaryConstants.c
Splint 3.1.2 --- 19 Oct 2016
Command Line: Setting +gnuextensions redundant with current value
binaryConstants.c:3:18: Parse Error. (For help on parse errors, see splint -help
parseerrors.)
*** Cannot continue.
$
是否有允许此扩展名为C的标志?