Cppcheck 2.16.0
C code (bitfields.c):
bitfields.c
#include <stdint.h> #include <stdio.h> struct foo { volatile uint32_t a : 10; volatile uint32_t /*reserved*/ : 6; volatile uint32_t b : 10; volatile uint32_t /*reserved*/ : 6; }; int main(void) { struct foo foo_ = {0}; for (uint32_t i = 0; i < (uint32_t)2; ++i) { printf("[%u] foo_ = %u\n", foo_.b); } return 0; }
cppcheck output:
> cppcheck bitfields.c Checking bitfield.c ... bitfield.c:13:5: error: syntax error [syntaxError] for (uint32_t i = 0; i < (uint32_t)2; ++i) { ^
Assigning dummy names to unnamed bitfields of struct foo makes the warning disappear.
struct foo
Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/13722
Log in to post a comment.
Cppcheck 2.16.0
C code (
bitfields.c
):cppcheck output:
Assigning dummy names to unnamed bitfields of
struct foo
makes the warning disappear.Last edit: Adel Mamin 2025-03-18
Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/13722