This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Revisiting generalized lvalues
- From: Andrew Pinski <pinskia at physics dot uc dot edu>
- To: mike at genlogic dot com (Michael Krasnik)
- Cc: gcc at gcc dot gnu dot org
- Date: Sat, 29 Oct 2005 11:28:46 -0400 (EDT)
- Subject: Re: Revisiting generalized lvalues
>
> I don't know if it's too late, but there is yet another reason
> for the use of generalized lvalues besides just ignorance:
> using them in macros that verify pointer and struct usage
> in a large framework. A comma expression makes it very
> convenient, for example (just a general idea):
>
> #ifdef PRODUCTION
> #define X_ABC(x) ( check( x ), x->abc )
> #else
> #define X_ABC(x) x->abc
> #endif
>
> which expands
>
> X_ABC(x) = y;
>
> to:
>
> ( check( x ), x->abc ) = y;
>
> It is something that is used during development only and
> is switched off for the production builds. C++ compatibility
> is not an issue either.
GCC does this through another extension, like:
#ifdef CHECKING
#define CHECK_X(x) ({const tree __t = x; check(__t); __t; })
#else
#define CHECK_X(x) x
#endif
#define X_ABC(x) CHECK_X(x)->abc
-- Pinski