有没有gcc标志可以禁止隐式的bool到int转换?
我想在这段代码中得到任何警告:
我想在这段代码中得到任何警告:
void function( int value, bool flag ) { }
int main()
{
int a = 123;
bool flag = true;
//oops, a common mistake
function( flag, a );
}
bool
,需要添加头文件#include <stdbool.h>
。 - pmgint
到bool
的“缩小”转换来检测。您可以对此发出警告。 - The Paramagnetic Croissant