I have a single instantiation of a struct called single_instance. This instance contains constants objects of type struct example_type.
typedef struct {
int n;
} example_type;
struct {
int some_variables;
// ...
const example_type t1;
const example_type t2;
// ...
} single_instance;
Let's say that I want to init single_instance.t1 to {1} and single_instance.t2 to {2}.
What is the most elegant way to do so?
Inline initialization is not possible:
struct {
int some_variables;
// ...
const example_type t1 = {1};
const example_type t2 = {2};
// ...
} single_instance;
This doesn't work too:
struct {
int some_variables;
// ...
const example_type t1;
const example_type t2;
// ...
} single_instance {0, {0}, {1}};
I have read multiple other threads related to this topic, however it seems that they all refer to initialize structs with "a name". In this case I want just one instantiation of single_instance, as such the type should not have a name.
=