Skip to content

Commit

Permalink
Update CHIPError.h for conditional constructor (#33540)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffryjacobd authored May 22, 2024
1 parent 1bbc450 commit 25cf97c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/lib/core/CHIPError.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class ChipError
* The result is valid only if CanEncapsulate() is true.
*/
constexpr ChipError(Range range, ValueType value) : ChipError(range, value, /*file=*/nullptr, /*line=*/0) {}
#if __cplusplus >= 202002L
#if CHIP_CONFIG_ERROR_SOURCE && __cplusplus >= 202002L
constexpr ChipError(Range range, ValueType value, const char * file, unsigned int line,
std::source_location location = std::source_location::current()) :
mError(MakeInteger(range, (value & MakeMask(0, kValueLength)))) CHIP_INITIALIZE_ERROR_SOURCE(file, line, location)
Expand All @@ -141,7 +141,7 @@ class ChipError
constexpr ChipError(Range range, ValueType value, const char * file, unsigned int line) :
mError(MakeInteger(range, (value & MakeMask(0, kValueLength)))) CHIP_INITIALIZE_ERROR_SOURCE(file, line, /*loc=*/nullptr)
{}
#endif // __cplusplus >= 202002L
#endif // CHIP_CONFIG_ERROR_SOURCE && __cplusplus >= 202002L

/**
* Construct a CHIP_ERROR for SdkPart @a part with @a code.
Expand All @@ -150,7 +150,7 @@ class ChipError
* The macro version CHIP_SDK_ERROR checks that the numeric value is constant and well-formed.
*/
constexpr ChipError(SdkPart part, uint8_t code) : ChipError(part, code, /*file=*/nullptr, /*line=*/0) {}
#if __cplusplus >= 202002L
#if CHIP_CONFIG_ERROR_SOURCE && __cplusplus >= 202002L
constexpr ChipError(SdkPart part, uint8_t code, const char * file, unsigned int line,
std::source_location location = std::source_location::current()) :
mError(MakeInteger(part, code)) CHIP_INITIALIZE_ERROR_SOURCE(file, line, location)
Expand All @@ -159,7 +159,7 @@ class ChipError
constexpr ChipError(SdkPart part, uint8_t code, const char * file, unsigned int line) :
mError(MakeInteger(part, code)) CHIP_INITIALIZE_ERROR_SOURCE(file, line, /*loc=*/nullptr)
{}
#endif // __cplusplus >= 202002L
#endif // CHIP_CONFIG_ERROR_SOURCE && __cplusplus >= 202002L

/**
* Construct a CHIP_ERROR constant for SdkPart @a part with @a code at the current source line.
Expand All @@ -180,7 +180,7 @@ class ChipError
* This is intended to be used only in foreign function interfaces.
*/
explicit constexpr ChipError(StorageType error) : ChipError(error, /*file=*/nullptr, /*line=*/0) {}
#if __cplusplus >= 202002L
#if CHIP_CONFIG_ERROR_SOURCE && __cplusplus >= 202002L
explicit constexpr ChipError(StorageType error, const char * file, unsigned int line,
std::source_location location = std::source_location::current()) :
mError(error) CHIP_INITIALIZE_ERROR_SOURCE(file, line, location)
Expand All @@ -189,7 +189,7 @@ class ChipError
explicit constexpr ChipError(StorageType error, const char * file, unsigned int line) :
mError(error) CHIP_INITIALIZE_ERROR_SOURCE(file, line, /*loc=*/nullptr)
{}
#endif // __cplusplus >= 202002L
#endif // CHIP_CONFIG_ERROR_SOURCE && __cplusplus >= 202002L

#undef CHIP_INITIALIZE_ERROR_SOURCE

Expand Down

0 comments on commit 25cf97c

Please sign in to comment.