binW binW - 1 year ago 82
C Question

What does this dot syntax mean in the Pebble watch development tutorial?

I came across following code in Pebble watch app development tutorial:

// 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

I cant understand this assignment to .load and .unload. Is this standard C? I don't think I have ever seen similar syntax before.

Answer Source

This is standard c99.

It is combining compound literals

 (WindowHandlers) {}

and designated initializers

.load = main_window_load,
.unload = main_window_unload
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download