-
Notifications
You must be signed in to change notification settings - Fork 7.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
stb_image_write: warning C4996: ... Consider using sprintf_s ... #1446
Comments
My work around is to place: I don't know if this is a good idea or not but it got rid of the warning. I'll know better once I start implementing my save function. FYI: keep up the good work. |
#pragma GCC diagnostic push /* also works on clang */
#pragma GCC diagnostic ignored "-Wunused-function"
#define HEADERLIB_IMPLEMENTATION
#include "headerlib.h"
#pragma GCC diagnostic pop I'd assume msvc would have similar construct - but I don't use msvc so cannot help you further.
AFAIU that macro should be defined by the implementation (i.e libc) if they support Annex K. I don't believe it's something the user is meant to define themselves (?) |
You make a good point about not using So I went with this:
Maybe you may consider using this wrapper in stb_image_write. as you already have the test condition to use sprintf_s if the requirements are met. Just a suggestion. You may close this issue otherwise if you want or is this something only I can do? |
We should just use sprintf_s instead as needed. It just requires conditional compilation to support all the compilers, so it requires search and testing to get right. |
Getting a similar warning on latest macOS / clang 14.0.3:
Would just using Thanks! |
For macOS / clang I create PR #1619. I hope it will be merged. |
I have the same issue currently I have to use this very ugly workaround: #ifndef __STDC_LIB_EXT1__
#define __STDC_LIB_EXT1__
#define sprintf_s snprintf
#endif
#define STB_IMAGE_WRITE_IMPLEMENTATION
#include <stb_image_write.h> @ismagilli I also hope your fix gets merged. |
During a MS VS C++ build, I get the following warning.
Expected behavior
The text was updated successfully, but these errors were encountered: