słowo static w rozmiarze tablicy

0

Witam.

Co znaczy poniższa konstrukcja. Nawet nie wiem co wpisać do google <shame>.

 
#define BUFF_SIZE sizeof("YYYY-MM-DD")
void foo(char buffer[]);//deklaracja
void foo(char buffer[static BUFF_SIZE]){...}//definicja

Interesuje mnie

char buffer[static BUFF_SIZE]

z naciskiem na [static BUFF_SIZE]


Pozdrawiam
3

Standard: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf
Strona: 27
Czytamy: 6.7.5.2, 6.7.5.3

Edit za radą z komentarza:

In addition to optional type qualifiers and the keyword static, the [ and ] may delimit an expression or *. If they delimit an expression (which specifies the size of an array), the
expression shall have an integer type. If the expression is a constant expression, it shall
have a value greater than zero. The element type shall not be an incomplete or function
type. The optional type qualifiers and the keyword
static
shall appear only in a
declaration of a function parameter with an array type, and then only in the outermost
array type derivation

A declaration of a parameter as ‘‘array of
type’’ shall be adjusted to ‘‘qualified pointer to type’’, where the type qualifiers (if any) are those specified within the [ and ]
of the array type derivation. If the keyword static also appears within the [ and ] of the
array type derivation, then for each call to the function, the value of the corresponding
actual argument shall provide access to the first element of an array with at least as many
elements as specified by the size expression

1

To nie jest poprawny syntax języka C++ (taki wpisałeś w tagach).

0
int fun(int a[static 5])

W C to oznacza: "kompilatorze pilnuj, aby nikt nie podał do tej funkcji tablicy mniejszej niż 5 elementów"

5

http://stackoverflow.com/questions/3430315/what-is-the-purpose-of-static-keyword-in-array-parameter-of-function-like-char

Jak szukać takich udziwnień? Bardzo prosto. 3 słowa:
static - bo to Cię interesuje
array - bo odnosi się do tablicy
index - bo jest używane niejako przy indeksie tablicy, a więc:
"static array index" i wyjdzie m.in. to, co Ci podałem :)

1 użytkowników online, w tym zalogowanych: 0, gości: 1