C++11 attributes for C11 (was Re: [PATCH] Generalized attribute support)
Hal Finkel
hfinkel at anl.gov
Mon Apr 21 14:17:01 PDT 2014
----- Original Message -----
> From: "Aaron Ballman" <aaron at aaronballman.com>
> To: "Alp Toker" <alp at nuanti.com>
> Cc: "Dean Sutherland" <dsutherland at cert.org>, "Richard Smith" <richard at metafoo.co.uk>, "llvm cfe"
> <cfe-commits at cs.uiuc.edu>
> Sent: Monday, April 21, 2014 4:04:24 PM
> Subject: Re: C++11 attributes for C11 (was Re: [PATCH] Generalized attribute support)
>
> On Sat, Apr 19, 2014 at 7:05 PM, Alp Toker <alp at nuanti.com> wrote:
> > Small update for the list..
> >
> > We discussed this at LLVM Europe 2014 and came to the conclusion
> > that we
> > might as well offer the feature behind an -f flag.
> >
> > This should satisfy user requests for C++11-style attributes in C11
> > without
> > prejudicing any standards process.
>
> Why just C11? If we're using a feature flag, wouldn't it make sense
> to
> expose this for C++98, or C99, or ObjC (presuming there are no
> ambiguities)?
+1
>
> > Thanks to the many detailed use-cases
> > people sent in that have made me more comfortable picking this up
> > again.
> >
> > So, I've got a slightly improved version of the patch and will aim
> > to rebase
> > and post it to the list for review in the coming weeks.
> >
> > All we need now is great name for the -f flag ;-)
>
> I like my bikesheds to be blue!
>
> -fcxx-style-attributes
> -fcxx-attributes
I think -fcxx-attributes is the better of the two; I think that there is no need for 'style' because the interpretation of the attributes and their allowed placement should be, in C, just the restriction of the C++ behavior naturally restricted to the C subset.
>
> I don't have a strong opinion on the name, but I do think that the
> feature flag should warn in nonsense situations (for instance
> -fno-cxx-attributes -std=c++11),
+1
> or maybe even -fcxx-attributes
> -std=c++11 (since it's redundant, but I'm less tied to this).
Please don't warn here. If we have a library that depends on this feature, then we'll want to add the flag to all *C*FLAGS variables without carefully considering which ones are C, which are C++03 and which are C++11, etc.
Thinking about it, however, I'm not sure that a compile flag is the right approach. If I'm distributing a set of header files, what probably works better is something like:
#if __has_feature(cxx_attributes)
#pragma cxx_attributes push
#endif
...
#pragma cxx_attributes pop
(with extra guards, likely different syntax, etc. but you get the idea).
-Hal
>
> ~Aaron
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
--
Hal Finkel
Assistant Computational Scientist
Leadership Computing Facility
Argonne National Laboratory
More information about the cfe-commits
mailing list