Repository navigation
Pedantic - #217
Pedantic#217
Conversation
…d identifier Signed-off-by: Steffen Pankratz <kratz00@gmx.de>
…eprecated in all versions of C Signed-off-by: Steffen Pankratz <kratz00@gmx.de>
…xtension Signed-off-by: Steffen Pankratz <kratz00@gmx.de>
Signed-off-by: Steffen Pankratz <kratz00@gmx.de>
There was a problem hiding this comment.
Pull request overview
This PR modernizes the codebase to use C23 standard compliance instead of relying on GCC-specific extensions. The changes replace deprecated and non-standard constructs with their C23 equivalents to improve portability and prepare for GCC 15 which will default to C23.
Changes:
- Replace deprecated
__FUNCTION__with standard__func__in logging macros - Replace GCC extension
##__VA_ARGS__with C23 standard__VA_OPT__(,) __VA_ARGS__syntax - Set CMake C standard to C23 and update test code to use
int main(void)instead ofint main() - Add
-Wpedanticcompiler flag to enforce strict standard compliance
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| lib/log.h | Updated logging macros to use __func__ and __VA_OPT__ instead of deprecated/GCC-specific constructs |
| CMakeLists.txt | Set C standard to C23 and updated test main() signatures to include void parameter |
| .github/workflows/cmake.yml | Added -Wpedantic flag to enforce strict standard compliance |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@kratz00 Whats are the pros and cons with setting CMAKE_C_STANDARD 17 instead? |
|
As long as C_STANDARD_REQUIRED (https://cmake.org/cmake/help/latest/prop_tgt/C_STANDARD_REQUIRED.html) is not set to ON it's more like a recommendation. |
|
Thanks, I suspected it was something like that! |
https://gcc.gnu.org/onlinedocs/gcc-3.3.5/gcc/Function-Names.html
Note that these semantics are deprecated, and that GCC 3.2 will handle __FUNCTION__ and __PRETTY_FUNCTION__ the same way as __func__. __func__ is defined by the ISO standard C99:##__VA_ARGS__ is GCC extension, an equivalent feature was added with the C23 standard, namely: VA_OPT
See also https://en.wikipedia.org/wiki/Variadic_macro_in_the_C_preprocessor#Trailing_comma
As a side note, GCC 15 will use C23 by default.