jwt-cpp icon indicating copy to clipboard operation
jwt-cpp copied to clipboard

-Wdeprecated-declarations Warning

Open ambiennt opened this issue 9 months ago • 1 comments

What happened?

Using: https://github.com/nlohmann/json/commit/11aa5f944d17ed5b96250ca133bf33c5ca8b0161 https://github.com/Thalhammer/jwt-cpp/commit/e71e0c2d584baff06925bbb3aad683f677e4d498 https://github.com/openssl/openssl/commit/648366ad010b3b22c1f298d39934d72702b3fd55

Compiling with Clang-cl 20.1.1, and passing /W4 /DJWT_DISABLE_PICOJSON /std:c++latest

How To Reproduce?

#include <jwt-cpp/jwt.h>
#include <jwt-cpp/traits/nlohmann-json/defaults.h>

int main() {
    // *jwt.h(3530,70): warning : 'strerror' is deprecated: This function or variable may be unsafe. Consider using strerror_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. [-Wdeprecated-declarations]
    // *jwt.h(3546,27): warning : 'wcrtomb' is deprecated: This function or variable may be unsafe. Consider using wcrtomb_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. [-Wdeprecated-declarations]
    jwt::create();
}

Version

0.7.1

What OS are you seeing the problem on?

Windows

What compiler are you seeing the problem on?

Clang

Relevant log output

*jwt.h(3530,70): warning : 'strerror' is deprecated: This function or variable may be unsafe. Consider using strerror_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. [-Wdeprecated-declarations]
*jwt.h(3546,27): warning : 'wcrtomb' is deprecated: This function or variable may be unsafe. Consider using wcrtomb_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. [-Wdeprecated-declarations]

Code of Conduct

  • [x] I agree to follow this project's Code of Conduct

ambiennt avatar Apr 06 '25 23:04 ambiennt

https://en.cppreference.com/w/c/string/byte/strerror

As with all bounds-checked functions, strerror_s and strerrorlen_s are only guaranteed to be available if STDC_LIB_EXT1 is defined by the implementation and if the user defines STDC_WANT_LIB_EXT1 to the integer constant 1 before including <string.h>

These are not generally available and are an optional feature that's on my default for windows https://en.m.wikipedia.org/wiki/C11_(C_standard_revision) so there's a lack of compatibility to use them.

You can control this in your own project with https://stackoverflow.com/a/617586/8480874 for example.

prince-chrismc avatar Apr 07 '25 00:04 prince-chrismc