diff --git a/libs/common/include/launchdarkly/bindings/c/logging/log_level.h b/libs/common/include/launchdarkly/bindings/c/logging/log_level.h index 7d4698acc..7c26079d5 100644 --- a/libs/common/include/launchdarkly/bindings/c/logging/log_level.h +++ b/libs/common/include/launchdarkly/bindings/c/logging/log_level.h @@ -8,6 +8,7 @@ #include <stdbool.h> #include <stddef.h> +#include <stdint.h> #ifdef __cplusplus extern "C" { // only need to export C interface if @@ -23,8 +24,8 @@ enum LDLogLevel { LD_LOG_INFO = 1, LD_LOG_WARN = 2, LD_LOG_ERROR = 3, - LD_LOG_MAXVAL = 0x7FFFFFFF /* This is not a valid log level, it is used to - * ensure the enum is at least 32 bits. */ + LD_UNUSED_MAXVALUE = INT32_MAX /* Used to ensure the underlying type is + * at least 32 bits. */ }; /** diff --git a/libs/common/tests/logging_c_binding_test.cpp b/libs/common/tests/logging_c_binding_test.cpp index d3fc2ff42..bf01bb359 100644 --- a/libs/common/tests/logging_c_binding_test.cpp +++ b/libs/common/tests/logging_c_binding_test.cpp @@ -7,11 +7,11 @@ TEST(LogLevelTests, LogLevelToString) { ASSERT_STREQ("info", LDLogLevel_Name(LD_LOG_INFO, "unknown")); ASSERT_STREQ("warn", LDLogLevel_Name(LD_LOG_WARN, "unknown")); ASSERT_STREQ("error", LDLogLevel_Name(LD_LOG_ERROR, "unknown")); - ASSERT_STREQ("unknown", LDLogLevel_Name(LD_LOG_MAXVAL, "unknown")); + ASSERT_STREQ("unknown", LDLogLevel_Name(LD_UNUSED_MAXVALUE, "unknown")); } TEST(LogLevelTests, LogLevelToEnum) { - constexpr auto unknown = LD_LOG_MAXVAL; + LDLogLevel unknown = LD_UNUSED_MAXVALUE; ASSERT_EQ(LD_LOG_DEBUG, LDLogLevel_Enum("debug", unknown)); ASSERT_EQ(LD_LOG_INFO, LDLogLevel_Enum("info", unknown)); ASSERT_EQ(LD_LOG_WARN, LDLogLevel_Enum("warn", unknown));