Skip to content

Conversation

@jmacheta
Copy link
Member

This pull request introduces significant improvements to the portability and maintainability of the embeutils library's compiler attribute macros. The main focus is a major refactor of compiler_support.h to support multiple compilers in a portable way, with detailed documentation and robust feature detection. Additionally, the CMake install script is cleaned up for better readability and logging.

Enhancements to portable compiler attribute macros:

  • Refactored compiler_support.h to provide portable definitions for macros such as EMBEUTILS_PACKED, EMBEUTILS_NORETURN, EMBEUTILS_WEAK, EMBEUTILS_NODISCARD, EMBEUTILS_FALLTHROUGH, EMBEUTILS_INLINE, EMBEUTILS_RESTRICT, EMBEUTILS_UNUSED, EMBEUTILS_NONNULL, EMBEUTILS_STATIC_ASSERT, EMBEUTILS_ALIGNAS, and EMBEUTILS_ALIGNOF, supporting GCC, Clang, MSVC, IAR, and Keil compilers. The file now uses feature detection and standard attributes where available, and includes extensive documentation for each macro.

CMake script improvements:

  • Changed CMake message calls from STATUS to VERBOSE for less noisy output during header configuration and Doxygen header processing. [1] [2]
  • Reformatted multi-line CMake commands for improved readability. [1] [2]

@jmacheta jmacheta requested a review from Copilot September 27, 2025 22:22
Copy link

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 portability and maintainability of the embeutils library by significantly refactoring the compiler support macros and cleaning up the CMake install script for better readability and less verbose logging.

  • Major refactor of compiler_support.h to support multiple compilers (GCC, Clang, MSVC, IAR, Keil) with portable attribute macros
  • Addition of comprehensive documentation and feature detection for compiler attributes
  • CMake install script improvements with better formatting and reduced verbosity

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/include/embetech/compiler_support.h Complete refactor to provide portable compiler attribute macros with extensive documentation and multi-compiler support
cmake/install.cmake Formatting improvements and message verbosity reduction from STATUS to VERBOSE

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

#define EMBEUTILS_RESTRICT __restrict
#else
///@brief alias to C99 restrict keyword
#elif __STDC_VERSION_ >= 199901L
Copy link

Copilot AI Sep 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing underscore in __STDC_VERSION_ - should be __STDC_VERSION__

Suggested change
#elif __STDC_VERSION_ >= 199901L
#elif __STDC_VERSION__ >= 199901L

Copilot uses AI. Check for mistakes.
Comment on lines +76 to +84
#if defined(EMBEUTILS_COMPILER_GCC) || defined(EMBEUTILS_COMPILER_CLANG)
#define EMBEUTILS_WEAK __attribute__((weak))
#elif defined(EMBEUTILS_COMPILER_MSVC)
#define EMBEUTILS_WEAK __declspec(selectany)
#elif defined(EMBEUTILS_COMPILER_IAR) || defined(EMBEUTILS_COMPILER_KEIL)
#define EMBEUTILS_WEAK __weak
#else
#define EMBEUTILS_WEAK
#endif
Copy link

Copilot AI Sep 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent use of numeric comparison vs defined check. Lines 60-70 use (1 == EMBEUTILS_COMPILER_*) while this section uses defined(EMBEUTILS_COMPILER_*). This creates a mismatch since the compiler macros are defined as 1 but checked differently.

Copilot uses AI. Check for mistakes.
@sonarqubecloud
Copy link

@jmacheta jmacheta requested a review from lkrzak September 27, 2025 22:26
Copy link
Member

@lkrzak lkrzak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it

@jmacheta jmacheta merged commit 7b22e4b into main Sep 29, 2025
4 checks passed
@jmacheta jmacheta deleted the compiler_support_expansion branch September 29, 2025 09:42
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.

3 participants