Mar*_*ark 3 c printf gcc warnings types
我们清理了大量的警告.在某些情况下,我们将%s替换为%d.在我们意识到生成的代码无法编译之前,一切似乎都没问题 - 字符串已被数字替换.
注意:我在复制和粘贴时检出了错误的版本.fprintf字符串已被编辑!
GCC输出
fedex_plus/classes.c:2425:3:警告:格式'%s'需要类型为'char*'的参数,但参数3的类型为'int' [-Wformat]
第2424行和第2425行:
fprintf(file, "\n//\t%s_ptr create_TIE();\n\tIDL_Application_instance_ptr create_TIE();\n",
ENTITYget_CORBAname(entity));
Run Code Online (Sandbox Code Playgroud)
函数ENTITYget_CORBAname:
const char *
ENTITYget_CORBAname (Entity ent)
{
static char newname [BUFSIZ];
strcpy( newname, ENTITYget_name(ent) );
newname[0] = ToUpper (newname [0]);
return newname;
}
Run Code Online (Sandbox Code Playgroud)
Ale*_* C. 10
我敢打赌,没有任何的声明,ENTITYget_CORBAname
可在fprintf
现场.如果是这种情况,则默认为隐式签名:
int ENTITYget_CORBAname(...);
Run Code Online (Sandbox Code Playgroud)
因此关于结果类型的警告是int
.
检查您的代码-Wimplicit
(暗示-Wall
),或尝试放置
const char *ENTITYget_CORBAname (Entity ent);
Run Code Online (Sandbox Code Playgroud)
在该fprintf
行之前,检查警告是否消失.如果是这样,那么你可能会错过一个标题.