What does the syntax for this point mean in the Pebble watch design tutorial?

I came across the following code in a pebble application 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 can not understand this purpose .load and .unload. Is this standard C? I do not think that I have seen a similar syntax before.

+3
source share
2 answers

This is the c99 standard.

It combines complex literals

  (WindowHandlers) {} 

and designated initializers

 .load = main_window_load, .unload = main_window_unload 
+7
source

I believe this is a standard C99 with an initialized constant struct with named fields when it is initialized.

By the way, this is also an extension of C -wrt to the older C - standards ( designated initializers ) provided by GCC

For the C11 standard, its final draft n1570 describes this syntax in "Β§6.7.9" Initialization "

+4
source

All Articles