diff --git a/src/error_handling.c b/src/error_handling.c index a0605373..ce99e66b 100644 --- a/src/error_handling.c +++ b/src/error_handling.c @@ -25,6 +25,7 @@ extern "C" #include #include #include +#define __STDC_WANT_LIB_EXT1__ 1 #include #include @@ -198,7 +199,11 @@ rcutils_set_error_state( error_state.line_number = line_number; #if RCUTILS_REPORT_ERROR_HANDLING_ERRORS // Only warn of overwritting if the new error is different from the old ones. +#ifdef __STDC_LIB_EXT1__ + size_t characters_to_compare = strnlen_s(error_string, RCUTILS_ERROR_MESSAGE_MAX_LENGTH); +#else size_t characters_to_compare = strnlen(error_string, RCUTILS_ERROR_MESSAGE_MAX_LENGTH); +#endif // assumption is that message length is <= max error string length static_assert( sizeof(gtls_rcutils_error_state.message) <= sizeof(gtls_rcutils_error_string.str), diff --git a/src/error_handling_helpers.h b/src/error_handling_helpers.h index 4914c4fe..07ef144a 100644 --- a/src/error_handling_helpers.h +++ b/src/error_handling_helpers.h @@ -36,6 +36,7 @@ #endif #include #include +#define __STDC_WANT_LIB_EXT1__ 1 #include #include @@ -130,7 +131,11 @@ __rcutils_convert_uint64_t_into_c_str(uint64_t number, char * buffer, size_t buf buffer[i] = '\0'; // reverse the string in place +#ifdef __STDC_LIB_EXT1__ + __rcutils_reverse_str(buffer, strnlen_s(buffer, 21)); +#else __rcutils_reverse_str(buffer, strnlen(buffer, 21)); +#endif } // do not use externally, internal function which is only to be used by error_handling.c