octave-maintainers
[Top][All Lists]
Advanced

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

Re: Positioning GCC_ATTR_DEPRECATED


From: Rik
Subject: Re: Positioning GCC_ATTR_DEPRECATED
Date: Tue, 29 Dec 2015 12:56:28 -0800

On 12/29/2015 12:35 PM, John W. Eaton wrote:
> On 12/27/2015 07:34 PM, John W. Eaton wrote:
>> On 12/26/2015 11:20 PM, Rik wrote:
>>> 12/26/15
>>>
>>> I would not have necessarily thought of this, but for the fact that
>>> this is
>>> already being done in ov.h.  For example,
>>>
>>> GCC_ATTR_DEPRECATED octave_idx_type capacity (void) const
>>>
>>> versus
>>>
>>> octave_value (const charMatrix& chm, bool is_string,
>>>                char type = '\'') GCC_ATTR_DEPRECATED;
>>
>> I didn't realize that it could be anywhere except the end.  If it can be
>> at the beginning, then move it there.  May as well move all of them. How
>> about putting it at the beginning on a separate line?
>

I have a local changeset that moves GCC_ATTR_DEPRECATED to the start of the
function declaration.  In order to continue to play around while the main
line build is broken I've used bookmarks to branch off.  As soon as the
build is restored I'll push this and a bunch of other changes.


> After looking at this a bit more, I found that attributes can be applied
> to function definitions as well as declarations, but only if they appear
> before the function name.  So something like
>
>   static void foobar (void) __attribute__ ((noreturn)) { ... }
>
> fails to compile, but
>
>   __attribute__ ((noreturn)) static void foobar (void) { ... }
>
> is OK.  I recently added separate declarations for some static functions
> just so that I could tag them with the noreturn attribute.  But now I see
> that I could have avoided teh duplication.  I'll fix that.
>
> Also, with C++11, "[[noreturn]]" is the standard way of specifying the
> noreturn attribute.
>
> So I think we should rename GCC_ATTR_NORETURN to be OCTAVE_ATTR_NORETURN
> (or something that does not appear to be specific to GCC) and then move
> all these attributes to be the first thing in the function declaration
> (or definition).
>

I think it's a good idea to rename to OCTAVE_ATTR_NORETURN.  But, I would
prefer to keep this attribute at the end of the declaration if possible. 
The attribute is a hint to the compiler, not the programmer, and is of
pretty low importance compared to items like the function return type, name
of function, what the acceptable input arguments are, etc.  Since it isn't
very relevant to the programmer I prefer to make it an innocuous tail at
the end of the declaration.  The GCC_ATTR_DEPRECATED attribute, by
contrast, is a hint to the programmer.  I want it to be the first thing
they see saying "Don't Use This Function!".

--Rik




reply via email to

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