Is there a way to declare a structure with default initalisation values?
I have a header file which defines a structur like this:
typedef struct struc_s
{
size_t cost const = 2000;
size_t dmg const = 100;
size_t def const = 100;
size_t hull const = 1500;
size_t shield const = 300;
size_t capacity const = 2;
size_t destruc const = 10;
} struc_t;
But this ofcourse doesn't work.
I would also be fine with a way of declaring a var of type struc_t
in this header file. But as I remember right. I would have to decalre it in the c file as extern
What I want to do is every where where this header is included i want to be able to do var = struc_s.dmg
and and the result should be that var holds the value 100
.
But I dont want to declare struc_s anywhere else then in the header. Is there a way to archive this behavior?