sprintf warnings

This commit is contained in:
Sean Barrett 2020-02-05 03:10:07 -08:00
parent 498bd3e017
commit f06f586d18
2 changed files with 5 additions and 5 deletions

View File

@ -182,7 +182,7 @@ PERFORMANCE vs MSVC 2008 32-/64-bit (GCC is even slower than MSVC):
#ifndef STB_SPRINTF_MIN
#define STB_SPRINTF_MIN 512 // how many characters per callback
#endif
typedef char *STBSP_SPRINTFCB(char *buf, void *user, int len);
typedef char *STBSP_SPRINTFCB(const char *buf, void *user, int len);
#ifndef STB_SPRINTF_DECORATE
#define STB_SPRINTF_DECORATE(name) stbsp_##name // define this before including if you want to change the names

View File

@ -111,10 +111,10 @@ int main()
#if __STDC_VERSION__ >= 199901L
#if USE_STB
CHECK4("Inf Inf NaN", "%g %G %f", INFINITY, INFINITY, NAN);
CHECK1("N", "%.1g", NAN);
CHECK2("N", "%.1g", NAN);
#else
CHECK4("inf INF nan", "%g %G %f", INFINITY, INFINITY, NAN);
CHECK1("nan", "%.1g", NAN);
CHECK2("nan", "%.1g", NAN);
#endif
#endif
@ -150,9 +150,9 @@ int main()
assert(strncmp(buf, "37778931862957161709568.000000", 17) == 0);
n = SNPRINTF(buf, 10, "number %f", 123.456789);
assert(strcmp(buf, "number 12") == 0);
assert(n == (USE_STB ? 9 : 17)); // written vs would-be written bytes
assert(n == 17); // written vs would-be written bytes
n = SNPRINTF(buf, 0, "7 chars");
assert(n == (USE_STB ? 0 : 7));
assert(n == 7);
// stb_sprintf uses internal buffer of 512 chars - test longer string
assert(SPRINTF(buf, "%d %600s", 3, "abc") == 603);
assert(strlen(buf) == 603);