[splint-discuss] Parse Error on Macro, help

Benno benjl at cse.unsw.edu.au
Tue Sep 5 23:41:25 EDT 2006


On Wed Sep 06, 2006 at 11:03:48 +0800, raymond wrote:
>I write a simple C program with a Macro like below:
>
>/*test.c*/
>  1 #include<unistd.h>
>  2 #include<stdio.h>
>  3 #include <stdlib.h>
>  4 #define MSG_COMMON_HEADER()                     \
>  5         u_int16_t len;                          \
>  6         u_int16_t type;
>  7
>  8 struct any_msg {
>  9           MSG_COMMON_HEADER ();
> 10 };


Won't this expand to:

struct any_msg {
	u_int16_t len;
	u_int16_t type;;
}

Note the doulbe semi-colon. I'm not sure if that is valid C or not.
It's definately not nice though.

Don't know if that is the problem or not, but could be.

Cheers,

Benno

> 12 int main( int argc , char** argv)
> 13 {
> 14         struct any_msg msg = {
> 15                 .type = 0,
> 16                 .len = 4};
> 17         printf( "msg.type = %d msg.len = %d\n", msg.type,msg.len);
> 18         return 0;
> 19 }
>
>Using the splint cmd:
>	splint +posixlib macro_splint.c
>it outputs:
>	
>        Splint 3.1.1 --- 06 Jan 2006
>        
>        macro_splint.c:9:13: Parse Error. (For help on parse errors, see
>        splint -help
>                       parseerrors.)
>        *** Cannot continue.
>It seems like splint can't parse the MSG_COMMON_HEADER() macro.
>
>Has anyone met this problem?
>
>Thanks a lot
>
>
>_______________________________________________
>splint-discuss mailing list
>splint-discuss at ares.cs.Virginia.EDU
>http://www.cs.Virginia.EDU/mailman-2.1.5/listinfo/splint-discuss


More information about the splint-discuss mailing list