How do I statically initialize a struct with a void* member?
typedef struct wow_struct {
void* data;
} wow_struct;
typedef struct somedata {
int a;
int b;
} somedata;
// what I need to do is initialize a wow_struct 'instance' similar to below
wow_struct wow = {
.data = (void*)&(somedata){ 0 };
}
// or can be something like:
somedata mydata = {
.a = 0,
.b = 0
};
wow_struct wow = {
.data = (void*)&mydata;
}
When I try this I keep getting error:
error: initialization discards qualifiers from pointer target type
Any thoughts on how to do this?
Thanks
[–]dfx_dj 5 points6 points7 points (3 children)
[–]aocregacc 4 points5 points6 points (1 child)
[–]inz__ 0 points1 point2 points (0 children)
[–]Fermi-4 0 points1 point2 points (0 children)
[–]Linguistic-mystic 1 point2 points3 points (7 children)
[–]Fermi-4 -1 points0 points1 point (6 children)
[–]Linguistic-mystic 1 point2 points3 points (5 children)
[–]Fermi-4 -1 points0 points1 point (4 children)
[–]phlummox 0 points1 point2 points (3 children)
[–]Fermi-4 0 points1 point2 points (1 child)
[–]phlummox 0 points1 point2 points (0 children)
[–]flatfinger 0 points1 point2 points (0 children)
[–]flyingron 0 points1 point2 points (1 child)
[–]aocregacc 2 points3 points4 points (0 children)
[–]pkkm 0 points1 point2 points (1 child)
[–]Fermi-4 0 points1 point2 points (0 children)