-
Notifications
You must be signed in to change notification settings - Fork 78
Open
Description
Summary
The header include/utils/utils.h provides a portable shortcut for the GCC [[fallthrough]] attribute:
/* gcc attribute shorthands */
#ifndef __fallthrough
#if __GNUC__ >= 7
#define __fallthrough __attribute__((fallthrough))
#else
#define __fallthrough
#endif
#endifThe current test only checks for GCC ≥ 7. When the project is compiled with Clang, __fallthrough expands to an empty token, so any use of __fallthrough; does not suppress the -Wimplicit-fallthrough warning (or the newer -Wswitch).
This results in noisy warnings on macOS builds that use Clang, even though Clang has supported __attribute__((fallthrough)) for many releases.
Environment
| Item | Value |
|---|---|
| OS | macOS 26.0.1 |
| Compiler | Apple clang version 17.0.0 |
| Build system | CMake (default configuration) |
| Library version | master Commit c6d562e |
Steps to reproduce
# 1️⃣ Clone the repository
git clone https://github.com/goToMain/libosdp.git
cd libosdp
# 2️⃣ Create a build directory and configure with clang
mkdir build && cd build
cmake ..
# 3️⃣ Build
make # or `cmake --build .`The macro expands to nothing, so the attribute is not applied.
Proposed fix
Extend the condition to also enable the macro when compiling with Clang:
/* gcc/clang attribute shorthands */
#ifndef __fallthrough
#if __GNUC__ >= 7 || defined(__clang__)
#define __fallthrough __attribute__((fallthrough))
#else
#define __fallthrough
#endif
#endifMetadata
Metadata
Assignees
Labels
No labels