Bruno Haible <[email protected]> writes:

> Collin Funk wrote:
>> -extern size_t base_len (char const *filename) _GL_ATTRIBUTE_PURE;
>> +extern size_t base_len (char const *filename) _GL_ATTRIBUTE_PURE
>> +  _GL_ATTRIBUTE_NONNULL ();
>
> Why do you omit the argument number? Why don't you write
>     _GL_ATTRIBUTE_NONNULL ((1));
> ?
>
> Likewise for last_component.

They both work in this case. The GCC documentation says [1]:

    If no arg-index is given to the nonnull attribute, all pointer
    arguments are marked as non-null.

It gives an example stating that the following two declarations are
equivalent:

    extern void *
    my_memcpy (void *dest, const void *src, size_t len)
            __attribute__((nonnull (1, 2)));
    extern void *
    my_memcpy (void *dest, const void *src, size_t len)
            __attribute__((nonnull));

That said, I can put the argument number if that is your preference.

Collin

[1] https://gcc.gnu.org/onlinedocs/gcc/Common-Attributes.html

Reply via email to