[splint-discuss] Parse Error on Macro, help
raymond
raymond-xu at 126.com
Wed Sep 6 01:47:21 EDT 2006
>
> There's one more thing. Splint is a C89 checker, not a C99 checker.
> I'm sure we all long for it to become a C99 checker, and had I world
> enough and time I'd be in there hacking it myself. (Sadly, I don't.)
> The construction
>
> struct any_msg msg = {.type = 0, .len = 4};
>
> is new in C99; C89 did not support any form of named initialisation
> for structs, only positional.
>
> What's the right way to do it?
>
> #include <unistd.h>
> #include <stdio.h>
> #include <stdlib.h>
> #define MSG_COMMON_FIELDS \
> u_int16_t len; \
> u_int16_t type;
>
> struct any_msg {
> MSG_COMMON_FIELDS
> };
>
> int main(int argc, char** argv) {
> struct any_msg msg = {/*len*/ 4, /*type*/ 0};
>
> printf("msg.type = %d msg.len = %d\n", msg.type, msg.len);
> return 0;
> }
>
Thanks your advices, but when I try your code, splint doesn't work, it
still has the same parse error,
More information about the splint-discuss
mailing list