You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I looked up C function array parameter little used functionality. Here are the details.
When declaring an array parameters to a function in all versions of C and C++ for can use the normal common syntax:
f(T a[])
f(T a[N])
where T is a const/volatile qualified type (also restrict qualified for C). These parameter types decay to the type T*.
C99 and later versions of C allow the additional syntax
f(T a[OPT_KEYWORDS N])
f(T a[OPT_KEYWORDS *]) same as f(T a[OPT_KEYWORDS])
where OPT_KEYWORDS are used to require a array size and to add qualifiers to the pointer itself as opposed to the type of the pointer where the qualifiers are part of T. They can be one or more of the following:
static - hint: a is not NULL with at least N elements
const - type of a inside the function is Tconst
volatile - type of a inside the function is Tvolatile
restrict - type of a inside the function is T*restrict
The * indicates unknown size.
For example, the declaration
f(volatile int a[static const restrict 10])
would treat the type of a in the function f as if it were declared:
volatile int * const restrict a;
with the value of a being not null and containing at least 10 elements.
There is a lot more to mention about this, but I wanted to record Jim's notes first.
The text was updated successfully, but these errors were encountered:
@kupsch Notes
I looked up C function array parameter little used functionality. Here are the details.
When declaring an array parameters to a function in all versions of C and C++ for can use the normal common syntax:
where T is a const/volatile qualified type (also restrict qualified for C). These parameter types decay to the type T*.
C99 and later versions of C allow the additional syntax
where OPT_KEYWORDS are used to require a array size and to add qualifiers to the pointer itself as opposed to the type of the pointer where the qualifiers are part of T. They can be one or more of the following:
static - hint: a is not NULL with at least N elements
const - type of a inside the function is Tconst
volatile - type of a inside the function is Tvolatile
restrict - type of a inside the function is T*restrict
The * indicates unknown size.
For example, the declaration
would treat the type of a in the function f as if it were declared:
with the value of a being not null and containing at least 10 elements.
There is a lot more to mention about this, but I wanted to record Jim's notes first.
The text was updated successfully, but these errors were encountered: