This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] gcc/doc: list what version each attribute was introduced in
- From: Mike Stump <mikestump at comcast dot net>
- To: Jeff Law <law at redhat dot com>
- Cc: "Daniel P. Berrange" <berrange at redhat dot com>, gcc-patches at gcc dot gnu dot org
- Date: Fri, 7 Jul 2017 12:33:50 -0700
- Subject: Re: [PATCH] gcc/doc: list what version each attribute was introduced in
- Authentication-results: sourceware.org; auth=none
- References: <20170706132518.GO3988@redhat.com> <81cbdb30-0e18-0079-6cad-d781cf332bdf@redhat.com>
On Jul 7, 2017, at 10:01 AM, Jeff Law <law@redhat.com> wrote:
>
> On 07/06/2017 07:25 AM, Daniel P. Berrange wrote:
>> There are several hundred named attribute keys that have been
>> introduced over many GCC releases. Applications typically need
>> to be compilable with multiple GCC versions, so it is important
>> for developers to know when GCC introduced support for each
>> attribute.
> Keying on version #s is generally a terrible way to make your code
> portable.
> It's far better to actually *test* what your particular compiler
> compiler supports
So, if someone wanted to explore ways to make code that uses these better; a possibility might be to use __has_builtin a la clang:
https://clang.llvm.org/docs/LanguageExtensions.html
It also has __has_feature and __has_extension. At least it seems reasonably complete, and then people can feature test specific bits on a fine grained basis.
It doesn't solve history (without a re-release of old versions), but, it can provide a framework for solving the problem for the future.