Skip to content

Commit

Permalink
fix: deprecated use of std::char_traits<unsigned short>::length
Browse files Browse the repository at this point in the history
@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]
  • Loading branch information
Clement-Devevey authored Jan 20, 2025
1 parent 27d1be5 commit d98bbdf
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/java/org/bytedeco/javacpp/tools/Generator.java
Original file line number Diff line number Diff line change
Expand Up @@ -1042,7 +1042,7 @@ boolean classes(boolean handleExceptions, boolean defineAdapters, boolean conver
out.println(" if (ptr == NULL) {");
out.println(" return NULL;");
out.println(" }");
out.println(" return JavaCPP_createStringFromUTF16(env, ptr, std::char_traits<unsigned short>::length(ptr));");
out.println(" return JavaCPP_createStringFromUTF16(env, ptr, std::char_traits<char16_t>::length(ptr));");
out.println("}");
out.println();
}
Expand Down Expand Up @@ -2569,7 +2569,7 @@ void call(MethodInformation methodInfo, String returnPrefix, boolean secondCall)
// special considerations for char arrays as strings
if (asUtf16(methodInfo, k)) {
out.print(indent + "memcpy(");
suffix = ", (std::char_traits<unsigned short>::length(ptr" + k + ") + 1) * sizeof(unsigned short))";
suffix = ", (std::char_traits<char16_t>::length(ptr" + k + ") + 1) * sizeof(unsigned short))";
} else {
out.print(indent + "strcpy((char*)");
}
Expand Down

0 comments on commit d98bbdf

Please sign in to comment.