[splint-discuss] Parse Error on Macro, help

Michael Wojcik Michael.Wojcik at microfocus.com
Wed Sep 6 08:00:45 EDT 2006


> From: splint-discuss-bounces at cs.virginia.edu 
> [mailto:splint-discuss-bounces at cs.virginia.edu] On Behalf Of 
> James Dennett
> Sent: Wednesday, 06 September, 2006 01:35
> To: splint-discuss at cs.virginia.edu
> 
> Richard A. O'Keefe wrote:
> > raymond <raymond-xu at 126.com> wrote:
> > 	  4 #define MSG_COMMON_HEADER()                     \
> > 	  5         u_int16_t len;                          \
> > ====>	  6         u_int16_t type;
> >
> > Note 1: having empty parentheses in a macro definition is
technically
> > undefined in C89.  (I'm not sure, it might be illegal.)
> >   
> Are you sure?  It's well-defined in C++98, which is almost identical
to 
> C89/90 in terms of preprocessing.  An empty parameter name is illegal,
> but the case of () defines a function-like macro with no arguments.

I think Richard's wrong about this one.  ISO 9899-1990 6.8.3 shows the
identifier-list as optional (it has the "opt" subscript in the "of the
form" sentence), and goes on to say "parameters are specified by the
optional list of identifiers".  The grammar in (non-normative) Annex B
agrees (B.3).

This hasn't changed in C99 (ISO 9899-1999 6.10.3 #10).

That said, I agree with him that using a function-like macro in an
object-like manner strikes me as poor style, and the rest of his
comments were spot-on.

-- 
Michael Wojcik
Principal Software Systems Developer
Micro Focus

michael.wojcik at microfocus.com
9420 Key West Avenue
Rockville, MD 20850
Direct: 517 676 0892
What would you like Micro Focus to do for you? Contribute your view by
visiting
http://www.microfocus.com/CustomerInsight.asp



More information about the splint-discuss mailing list