bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-gnulib] Re: [bug-gnulib] Re: new gnulib module "verify" for com


From: Bruno Haible
Subject: Re: [bug-gnulib] Re: [bug-gnulib] Re: new gnulib module "verify" for compile-time assertions
Date: Mon, 26 Sep 2005 14:30:04 +0200
User-agent: KMail/1.5

Paul Eggert wrote:
> > # define verify_type__(R) \
> >     struct { int verify_error_if_negative_size__ : (R) ? 2 : -1; }
>
> Thanks.  I installed that.

Now one more simplification is possible: A variable declaration does it
just as nicely as a function declaration. Tested with gcc, Solaris cc, IRIX cc.

*** lib/verify.h        23 Sep 2005 22:59:59 -0000      1.5
--- lib/verify.h        26 Sep 2005 12:30:01 -0000
***************
*** 35,41 ****
  /* Verify requirement R at compile-time, as a declaration.  */
  
  # define verify(R) \
!     extern int (* verify_function__ (void)) [sizeof (verify_type__ (R))]
  
  /* Verify requirement R at compile-time, as an expression.
     This macro can be used in some contexts where verify cannot, and vice 
versa.
--- 35,41 ----
  /* Verify requirement R at compile-time, as a declaration.  */
  
  # define verify(R) \
!     extern int verify_variable__ [sizeof (verify_type__ (R))]
  
  /* Verify requirement R at compile-time, as an expression.
     This macro can be used in some contexts where verify cannot, and vice 
versa.


Bruno





reply via email to

[Prev in Thread] Current Thread [Next in Thread]