Skip to content

Commit c858714

Browse files
committed
Fix unsiged char size for clang-18 and linux
1 parent b2d478d commit c858714

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

source/StringUtils.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,9 @@ namespace vx::string_utils {
241241
std::size_t size = _size;
242242
if ( !size ) {
243243

244+
#if defined __linux__ && defined __clang__ && __clang_major__ >= 18
245+
size = std::strlen( reinterpret_cast<const char *>( _uchr ) );
246+
#else
244247
std::basic_string<unsigned char> string {};
245248
try {
246249

@@ -250,10 +253,11 @@ namespace vx::string_utils {
250253

251254
logFatal() << _exception.what();
252255
}
253-
#ifdef _WIN32
256+
#ifdef _WIN32
254257
size = std::strnlen_s( reinterpret_cast<const char *>( _uchr ), string.size() ); // NOSONAR do not use reinterpret_cast.
255-
#else
258+
#else
256259
size = std::strnlen( reinterpret_cast<const char *>( _uchr ), string.size() ); // NOSONAR do not use reinterpret_cast.
260+
#endif
257261
#endif
258262
}
259263
return std::make_optional<std::string>( _uchr, _uchr + size ); // NOSONAR do not use pointer arithmetic.

0 commit comments

Comments
 (0)