nothings / stb

stb single-file public domain libraries for C/C++
https://twitter.com/nothings
Other
25.99k stars 7.67k forks source link

Do not rely on __STDC_LIB_EXT1__ for sprintf_s #1512

Open eliemichel opened 11 months ago

eliemichel commented 11 months ago

It is not reliable at least on some versions of Clang (e.g., v14.1 on macOS 13.5.1), and anyway the safe _s functions are mostly a MSVC thing that they try and force to use through a warning but is barely standard.

Only stb_image_write was still using that, this PR aligns it to the behavior of e.g. stb_ds

eliemichel commented 10 months ago

Additional edit: use snprintf instead of sprintf, which is deprecated by clang, avoiding this warning:

error: 'sprintf' is deprecated: This function is provided for compatibility reasons only.  Due to security concerns inherent in the design of sprintf(3), it is highly recommended that you use snprintf(3) instead.