Skip to content

Conversation

Lzw655
Copy link
Collaborator

@Lzw655 Lzw655 commented Jul 3, 2025

feat(log): update CXX log trace guard for compatibility with GNU++20 and below

@Copilot Copilot AI review requested due to automatic review settings July 3, 2025 14:42
Copy link

@Copilot Copilot AI left a 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 and FixedString 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 optionally cxx_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:
Copy link
Preview

Copilot AI Jul 3, 2025

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.

Suggested change
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
Copy link
Preview

Copilot AI Jul 3, 2025

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.

@Lzw655 Lzw655 force-pushed the feat/update_cxx_log_trace_guard branch from cb3b86b to 6937378 Compare July 3, 2025 14:46
@Lzw655 Lzw655 force-pushed the feat/update_cxx_log_trace_guard branch from 6937378 to ab6a469 Compare July 3, 2025 14:52
@Lzw655 Lzw655 merged commit 00c7e62 into master Jul 3, 2025
9 checks passed
@Lzw655 Lzw655 deleted the feat/update_cxx_log_trace_guard branch July 3, 2025 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant