Skip to content
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: std::char_traits is deprecated for other type than char #748

Closed
wants to merge 1 commit into from

Conversation

Clement-Devevey
Copy link

Issue was the following:

`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));
^
char_traits.h:79:8: note: 'char_traits' has been explicitly marked deprecated here
struct LIBCPP_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.")
^
c++/v1/__config:772:53: note: expanded from macro 'LIBCPP_DEPRECATED'

define LIBCPP_DEPRECATED(m) attribute((deprecated(m)))`

@Clement-Devevey
Copy link
Author

Clement-Devevey commented Mar 15, 2024

Or
return JavaCPP_createStringFromUTF16(env, ptr, std::char_traits<char16_t>::length(reinterpret_cast<const char16_t*>(ptr)));
not sure what's best

@saudet
Copy link
Member

saudet commented Mar 16, 2024

That doesn't sound like a correct fix. We need to know the length of the string in UTF-16.

char16_t is only available since C++11, so we need to use something else.

@saudet
Copy link
Member

saudet commented Apr 6, 2024

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?

@saudet
Copy link
Member

saudet commented Aug 4, 2024

@Clement-Devevey 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!

@Clement-Devevey
Copy link
Author

@Clement-Devevey 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!

what an exciting news, thanks a lot :)

@saudet
Copy link
Member

saudet commented Aug 7, 2024

You'll open another PR with the change?

@saudet
Copy link
Member

saudet commented Aug 11, 2024

Duplicate of #753

@saudet saudet marked this as a duplicate of #753 Aug 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants