Ignore C4996
Is your feature request related to a problem? Please describe.
Well, I know to have support older functions, but MSVS blocks running because of sprintf. I think it will be better to turn off this warning.
Describe the solution you'd like
Add #pragma warning(disable : 4996) to file.
Describe alternatives you've considered I think it is no other solution.
Additional context None
have you tried setting the define _CRT_SECURE_NO_WARNINGS? (i.e. /D_CRT_SECURE_NO_WARNINGS )
This can be used to suppress the MSVC warnings like this: error C4996: 'strncpy': This function or variable may be unsafe. Consider using strncpy_s instead.
have you tried setting the define _CRT_SECURE_NO_WARNINGS? (i.e. /D_CRT_SECURE_NO_WARNINGS )
Yea, but to be honest, is it make sense to define this all the time? Better for me if it's defined on file at start
Not everyone uses MSVS. If you add the define prior to the include, you'll have no issue.
We generally prefer to avoid using _CRT_SECURE_NO_WARNINGS since that will affect compilation of the user's code, and similarly we prefer to avoid using #pragmas to disable warnings, and instead fix the code to avoid the warnings.
Please specify what library is triggering the warning.
[...] we prefer to avoid using #pragmas to disable warnings, and instead fix the code to avoid the warnings.
You have a point, but I think there is no code fix. MSVS "shouts" at me that one function is deprecated and not secure, and this library use that function (which function? I mentioned before - sprintf). If I am right, it is used to support other devices that they don't support suggested alternative (sprintf_s).
Please specify what library is triggering the warning.
stb_image_write.h causes the warning.
This used to work differently, see #744.
I'm not really sure how any of this is supposed to work.
Also, just to be clear, I assume you're using "MSVS" to refer to Microsoft Visual Studio C/C++ compiler, and it's not some other weird compiler I've never heard of. Google autocorrects the search MSVS compiler to MSVC compiler.
Okay, I was busy at that time, so sorry that I am answering rn
This used to work differently, see https://github.com/nothings/stb/issues/744.
I'm not really sure how any of this is supposed to work.
To be honest, I don't know that too. The funniest thing is that I have sprintf_s. Just made this test:
char buffer[50];
int result = sprintf_s(buffer, sizeof(buffer), "Test: %d", 123);
if (result >= 0) {
printf("sprintf_s working fine: %s\n", buffer);
return 0;
}
else {
printf("sprintf_s is not enabled on this.\n");
return 1;
}
...and the result is like that:
Also, I checked if the sprintf_s in stb_image_write.h will work anyway:
And the file was created... really, zero errors.
So to sum up, the problem is in __STDC_LIB_EXT1__.
I can upload the C++ file with the modified package. I also fixed there somehow the bug that min and max was duplicated when compiled.
Also, just to be clear, I assume you're using "MSVS" to refer to Microsoft Visual Studio C/C++ compiler, and it's not some other weird compiler I've never heard of. Google autocorrects the search
MSVS compilertoMSVC compiler.
I think yea. I mean, I referred to Microsoft Visual Studio as a program, not as a compiler, but it can be my fault.
Okay, I see #1257 pull request. I will check it probably tommorow, and I'll let you know.
I also met this warning on MSVC. Is it ok to use __STDC_SECURE_LIB__ to check if sprintf_s exists on MSVC? But I haven't found any official document talking about this macro