On Wed, 13 Nov 2013, Michael Matz wrote:

> Hi,
> 
> On Wed, 13 Nov 2013, Joseph S. Myers wrote:
> 
> > +In GNU C, but not GNU C++, you may also declare the type of a variable
> > +as @code{__auto_type}.  In that case, the declaration must declare
> > +only one variable,
> 
> What's the reason for this restriction?  I can't see what would become 
> ambiguous with allowing multiple declarations (even when mixing types):
> 
>   int i;
>   short s;
>   __auto_type i2 = i, s2 = s;
> 
> (i2 would be int, s2 be short).

__auto_type is thought of as being equivalent to typeof (initializer), 
except for avoiding multiple evaluation; there aren't any existing cases 
in GNU C where the type specifier is interpreted separately for each 
identifier being declared.  Obviously you can define semantics (following 
C++) for more cases, but the minimal version is sufficient for 
<stdatomic.h> and other similar uses in macros, and keeping it minimal 
reduces the risk of incompatibility with any future addition of such a 
feature to ISO C.  (It's also simplest to implement.)

-- 
Joseph S. Myers
jos...@codesourcery.com

Reply via email to