-
Notifications
You must be signed in to change notification settings - Fork 590
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
Fix use of deprecated std::char_traits<unsigned short>::length #753
base: master
Are you sure you want to change the base?
Conversation
Some versions of clang - particularly the one on MacOS - emitted the following warning when compiling javacpp: > `jniNativeLibrary.cpp:314:57: warning: 'char_traits' is deprecated: > char_traits for T not equal to char, wchar_t, char8_t, char16_t or > char32_t is non-standard and is provided for a temporary period. It > will be removed in LLVM 18, so please migrate off of it. > [-Wdeprecated-declarations] return JavaCPP_createStringFromUTF16(env, > ptr, std::char_traits::length(ptr)); This commit fixes that warning by adding a function JavaCPP_stringLength for strings of unsigned short.
Maybe we could just put an ifdef else endif in there that uses char16_t for C++11 compilers and keep using unsigned short if not? |
Either using a custom null-seeking function or an BTW, I see usage of |
That's just for platform dependent support of wchar, not UTF-16 or UTF-32 |
@codeinred Since we've decided to make C++11 a requirement for future versions of JavaCPP, let's just replace unsigned short with char16_t. Thanks! |
@codeinred Since we've decided to make C++11 a requirement for future versions of JavaCPP, let's just replace unsigned short with char16_t. Thanks! _Originally posted by @saudet in bytedeco#753 (comment) warning: 'char_traits<unsigned short>' is deprecated: char_traits<T> for T not equal to char, wchar_t, char8_t, char16_t or char32_t is non-standard and is provided for a temporary period. It will be removed in LLVM 19, so please migrate off of it. [-Wdeprecated-declarations]
Some versions of clang - particularly the one on MacOS - emitted the following warning when compiling javacpp:
This commit fixes that warning by adding a function JavaCPP_stringLength for strings of unsigned short.
Related Pull Requests & Issues
#748 was added with the same goal of fixing issue, however the concern raised there was that
char16_t
is not available pre-c++11. This PR aims to fix that issue by instead providing a clean implementation in standard C++.If merged, this PR should resolve Issue #710.
Performance Implications
There should be no performance difference for this change versus using
std::chair_traits<unsigned short>::length
, because it appears that compilers do not handlestd::char_traits<unsigned short>::length
as a special case in the way they dostrlen
.See this godbolt link for reference.
Assembly output is identical between the standard library implementation, and the one provided in this commit.
Implementation:
Assembly: