Anders Lind
Anders Lind

Reputation: 4840

"." as the start of variable name in struct

const struct file_operations generic_ro_fops = {
  .llseek         = generic_file_llseek,
  .read           = do_sync_read,
  .aio_read       = generic_file_aio_read,
  .mmap           = generic_file_readonly_mmap,
  .splice_read    = generic_file_splice_read,
  };

What do those ". " mean in this code?

This is from linux kernel fs/read_write.c

FYI http://lxr.linux.no/linux+v3.2.8/fs/read_write.c

Upvotes: 2

Views: 108

Answers (2)

MByD
MByD

Reputation: 137442

This is a GCC feature to initialize specific fields in the struct. See more here.

Upvotes: 3

cnicutar
cnicutar

Reputation: 182774

They're called "designated initializers". It's a feature introduced in C99 and provided as an extension by GNU C (of course you know, the Linux kernel isn't written in C but in GNU C).

This is really syntactic sugar and provides a convenient way to initialize the members of that struct without worrying about their order.

Upvotes: 5

Related Questions