Skip to main content

All Questions

Tagged with
2 votes
1 answer
59 views

Using previously set fields when initializing structure with compound literals

What is the expected behavior of referring to previously set fields, when declaring initial values for a struct using compound literal: Specifically is it ok to: struct foo v = { .v1 = ..., .v2 = .v1+...
dash-o's user avatar
  • 14.2k
4 votes
2 answers
118 views

Function pointer compatibility between single pointer and empty parameter lists

I've been reading about function pointer compatibility, but have not found the following scenario documented as being acceptable (below). With this code, it is allowed (without warnings) to call a ...
zambetti's user avatar
3 votes
2 answers
243 views

Initialize block-scope static const variable with pointer to compound literal?

The following code is rejected by GCC and Clang (godbolt link): struct thing; typedef enum { THING_TYPE_A, THING_TYPE_B, } thing_type_t; typedef struct thing_a { int i; } thing_a_t; typedef ...
Charles Nicholson's user avatar