Co robi kropka (.) mean in a struct initializer?
static struct fuse_oprations hello_oper = {
.getattr = hello_getattr,
.readdir = hello_readdir,
.open = hello_open,
.read = hello_read,
};
Nie rozumiem dobrze składni C. Nie mogę nawet szukać, bo nie znam nazwy składni. Co to? 87
Author: Jeegar Patel, 2011-11-08
3 answers
Jest to funkcja C99, która pozwala ustawić określone pola struktury według nazwy w inicjalizatorze. Wcześniej inicjalizator musiał zawierać tylko wartości dla wszystkich pól, w kolejności -- co oczywiście nadal działa.
Więc dla następującej struktury:
struct demo_s {
int first;
int second;
int third;
};
...możesz użyć
struct demo_s demo = { 1, 2, 3 };
...lub:
struct demo_s demo = { .first = 1, .second = 2, .third = 3 };
...albo nawet:
struct demo_s demo = { .first = 1, .third = 3, .second = 2 };
...chociaż dwa ostatnie są tylko dla C99.
112
Author: Dmitri,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2011-11-08 07:48:47
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2011-11-08 07:48:47
Są to inicjalizatory C99 oznaczone jako inicjalizatory .
19
Author: Dan Aloni,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2011-11-08 08:18:09
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2011-11-08 08:18:09
Jego znane jako designated initialisation
(patrz wyznaczone Inicjalizatory ). "Initializer-list", Każdy '.
' jest
"designator
", który w tym przypadku określa konkretnego członka
'fuse_oprations
' struct to initialize for the object designed by
identyfikator " hello_oper
".
13
Author: COD3BOY,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2011-11-08 13:55:50
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2011-11-08 13:55:50