Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

    struct group_info init_groups = { .usage = ATOMIC_INIT(2) };
Is this legal ANSI C?

You can initialize structs using .field = value ? Or is something else going on here?




http://lxr.free-electrons.com/source/kernel/groups.c

this should be the file i used. seems correct that way.


If by ANSI C you mean C89, then no. It was added in C99. I believe the feature is technically known as a "designated initializer".

(http://www.open-std.org/jtc1/sc22/WG14/www/docs/n1256.pdf section 6.7.8)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: