Reputation: 1053
We cleaned up a large number of warnings. In several cases, we replaced %s
with %d
. Everything seemed OK until we realized that the generated code wouldn't compile - strings had been replaced by numbers.
NOTE: I had the wrong revision checked out when I did the copy & paste. The fprintf
string has been edited!
GCC output
fedex_plus/classes.c:2425:3: warning: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘int’ [-Wformat]
lines 2424 and 2425:
fprintf(file, "\n//\t%s_ptr create_TIE();\n\tIDL_Application_instance_ptr create_TIE();\n",
ENTITYget_CORBAname(entity));
function ENTITYget_CORBAname:
const char *
ENTITYget_CORBAname (Entity ent)
{
static char newname [BUFSIZ];
strcpy( newname, ENTITYget_name(ent) );
newname[0] = ToUpper (newname [0]);
return newname;
}
Upvotes: 3
Views: 11959
Reputation: 28846
I assume that ENTITY_GETCorbaName()
returns a string, so if you want to print that, use %s
. If you want to print it as pointer, use %p
.
Upvotes: 1
Reputation: 27240
use %s
in your printf
to print that string or use %p
in your printf
to show pointer value you can also use %lld
to prints its value
Upvotes: 0
Reputation: 56996
My bet is that no declaration of ENTITYget_CORBAname
is available at the fprintf
spot. Should this be the case, it defaults to the implicit signature:
int ENTITYget_CORBAname(...);
hence the warning about the result type being an int
.
Check your code with -Wimplicit
(implied by -Wall
), or try to put
const char *ENTITYget_CORBAname (Entity ent);
before the fprintf
line and check if the warning disappears. If it does, then you're likely missing a header.
Upvotes: 11