I have the following function for Logging purposes:
<code>void LogE(const char* scope, const char* s, ...) {
fprintf(stderr, "%s : ", scope);
va_list list;
va_start(list, s);
vfprintf(stdout, s, list);
fprintf(stdout, "n");
va_end(list);
fflush(stdout);
}
</code>
<code>void LogE(const char* scope, const char* s, ...) {
fprintf(stderr, "%s : ", scope);
va_list list;
va_start(list, s);
vfprintf(stdout, s, list);
fprintf(stdout, "n");
va_end(list);
fflush(stdout);
}
</code>
void LogE(const char* scope, const char* s, ...) {
fprintf(stderr, "%s : ", scope);
va_list list;
va_start(list, s);
vfprintf(stdout, s, list);
fprintf(stdout, "n");
va_end(list);
fflush(stdout);
}
and it’s called like this:
<code>LogE(__func__, "No sufficient memory to add sorted triangle, current capacity (bytes) / requested (bytes): %d (%d) / %d (%d)", renderer->sortedTriangleCap, renderer->sortedTriangleCap * sizeof(SORTED_TRIANGLE));
</code>
<code>LogE(__func__, "No sufficient memory to add sorted triangle, current capacity (bytes) / requested (bytes): %d (%d) / %d (%d)", renderer->sortedTriangleCap, renderer->sortedTriangleCap * sizeof(SORTED_TRIANGLE));
</code>
LogE(__func__, "No sufficient memory to add sorted triangle, current capacity (bytes) / requested (bytes): %d (%d) / %d (%d)", renderer->sortedTriangleCap, renderer->sortedTriangleCap * sizeof(SORTED_TRIANGLE));
If I would use printf
function family directly, the compiler would complain/warn that the amount of varargs is less than the number of format specifiers in the format string.
Can I tell my compiler in C99 that const char* s
and ...
should be checked against each other?