I'd say I have intermediate experience with programming in c, however I've never seen this syntax used before to make a function. This reminds me of the syntax for a JQuery event. Overall, I'd like a detailed explanation of what this is and what the alternative syntax could be.A link to where I could read more about this in particular would be great too.
// Set handlers to manage the elements inside the Window
window_set_window_handlers(s_main_window, (WindowHandlers) {
.load = main_window_load,
.unload = main_window_unload
});
This is a code snippet from the Pebble WatchApp tutorial.
This is a function call making use of a compound literal. It is equivalent to the following:
The above also makes use of designated initializers, where you can specify fields to initialize by name.
Assuming
WindowHandlerscontains onlyloadandunloadin that order, the above is equivalent to:The C standard goes into these in more detail.
From section 6.5.2.5:
From section 6.7.8: