Re: "restrict" in brackets - what is this?

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

 



This is a C99 feature. Essentially, since arrays are implicitly converted to pointers when passed to functions, this:
void foo(char s[restrict]);
is equivalent to this:
void foo(char *restrict s);

Note that the [.size] notation is neither a C feature nor a GCC extension; it's a notational convenience used in the Linux man pages. The proper way to declare a function that takes an array of a specified size is to use the static qualifier like so:
void foo(size_t array_size, char s[static array_size]);
which specifies that s must point to at least array_size elements when the function is called.

If the size argument needs to come after the array parameter, then that's what the GCC extension of being able to forward declare parameters is for:
void foo(size_t size; char [static size], size_t size);

Attachment: signature.asc
Description: This is a digitally signed message part

Attachment: smime.p7s
Description: S/MIME cryptographic signature


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux