【发布时间】:2010-10-29 20:07:01
【问题描述】:
这段代码:
Int32 status;
printf("status: %x", status)
给我以下警告:
jpegthread.c:157: warning: format '%x' expects type 'unsigned int', but argument 3 has type 'Int32'
我知道我可以通过强制转换类型来摆脱它,但是是否可以使用 GCC 编译器标志来摆脱那种特定类型的警告,并且仍然使用 -Wall?
【问题讨论】:
-
你实际上应该做的是包含
<inttypes.h>,然后是printf("status : %" PRIx32, status),并首先转换为无符号整数。 -
另外,如果可以的话,尝试使用
<stdint.h>中的标准intX_t类型,如果编写新代码,任何人都在阅读。