-
Notifications
You must be signed in to change notification settings - Fork 1
feat(log): update CXX log trace guard for compatibility with GNU++20 … #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enhances the logging utility by introducing a C++20-based log_trace_guard
with NTTP string support, while preserving a fallback for pre-C++20 builds. It also removes an explicit -std=gnu++20
flag and updates the changelog.
- Add
ESP_UTILS_LOG_CXX20_SUPPORT
macro andFixedString
NTTP template for C++20 - Provide a C++17 fallback implementation of
log_trace_guard
and adjust trace macros - Remove explicit C++20 compiler flag in CMake and document the change in
CHANGELOG.md
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
src/log/esp_utils_log.hpp | Introduce C++20 support guard, FixedString NTTP log guard template, and a fallback implementation |
CMakeLists.txt | Remove hardcoded -std=gnu++20 flag |
CHANGELOG.md | Add enhancement entry for C++20 compatibility |
Comments suppressed due to low confidence (2)
CMakeLists.txt:19
- Instead of dropping the C++ standard flag, explicitly declare the minimum required standard with
target_compile_features(${COMPONENT_LIB} PUBLIC cxx_std_17)
(and optionallycxx_std_20
), which is more maintainable and clear.
-Wno-missing-field-initializers
src/log/esp_utils_log.hpp:15
- Consider using __has_include(<source_location>) or checking __cpp_lib_source_location to more precisely detect std::source_location availability, since __cpp_nontype_template_args alone may not guarantee it.
#if __cplusplus >= 202002L && defined(__cpp_nontype_template_args)
|
||
// C++17 fallback implementation without FixedString and source_location | ||
class log_trace_guard { | ||
public: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Delete or disable the copy and move constructors and assignment operators (e.g., log_trace_guard(const log_trace_guard&) = delete;
) to prevent accidental copies and duplicate enter/exit logs.
public: | |
public: | |
log_trace_guard(const log_trace_guard&) = delete; | |
log_trace_guard(log_trace_guard&&) = delete; | |
log_trace_guard& operator=(const log_trace_guard&) = delete; | |
log_trace_guard& operator=(log_trace_guard&&) = delete; |
Copilot uses AI. Check for mistakes.
@@ -2,6 +2,10 @@ | |||
|
|||
## v0.2.3 - 2025-07-03 | |||
|
|||
### Enhancements: | |||
|
|||
* feat(log): update CXX log trace guard for compatibility with GNU++20 and below |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Use the more general term "C++20" instead of the compiler-specific "GNU++20" to keep the changelog consistent across toolchains.
Copilot uses AI. Check for mistakes.
cb3b86b
to
6937378
Compare
6937378
to
ab6a469
Compare
feat(log): update CXX log trace guard for compatibility with GNU++20 and below