Can anyone explain to me how this initialization structure actually works?
struct audio_policy_service_ops {
audio_io_handle_t (*open_duplicate_output)(void *service,audio_io_handle_t output1,
int (*close_output)(void *service, audio_io_handle_t output);audio_io_handle_t output2);
int (*suspend_output)(void *service, audio_io_handle_t output);
int (*restore_output)(void *service, audio_io_handle_t output);
};
They are now initialized as shown below:
struct audio_policy_service_ops aps_ops = {
open_duplicate_output : aps_open_dup_output,
close_output : aps_close_output,
suspend_output : aps_suspend_output,
restore_output : aps_restore_output,
};
+3
source to share
2 answers
This is GCC's non-standard initialization syntax for structs. It is colloquially referred to as the old-style GNU style init syntax. Its standard equivalent is something like
struct Foo bar = { .name1 = value1, .name2 = value2 };
You can read about this in the GCC documentation .
+7
source to share