M
Michael Press
The following code compiles with a warning this way
cc -c -DWHICH=1 try.c
try.c: In function 'foo':
try.c:12: warning: initialization discards qualifiers from pointer target type
and without a warning this way.
cc -c -DWHICH=2 try.c
What gives? Why can I not use my typedef pst?
___________________BEGIN___________________
typedef struct
{
int a;
int b;
} st;
typedef st *pst;
int foo(const void *x)
{
#if WHICH == 1
const pst s = x;
#elif WHICH == 2
const st *s = x;
#endif
}
int main(void)
{
pst arr;
foo(arr);
return 0;
}
____________________END____________________
cc -c -DWHICH=1 try.c
try.c: In function 'foo':
try.c:12: warning: initialization discards qualifiers from pointer target type
and without a warning this way.
cc -c -DWHICH=2 try.c
What gives? Why can I not use my typedef pst?
___________________BEGIN___________________
typedef struct
{
int a;
int b;
} st;
typedef st *pst;
int foo(const void *x)
{
#if WHICH == 1
const pst s = x;
#elif WHICH == 2
const st *s = x;
#endif
}
int main(void)
{
pst arr;
foo(arr);
return 0;
}
____________________END____________________