J
Jason Curl
Hello,
Just a clarification of the specification about the C-Standard's
interpretation of pointers.
I know that 'char *' and 'void *' are equivalent and that 'int *' may be
different in representation to 'char *' (but most often there is no
difference on modern compilers/machines).
So if I define a function such as (e.g. often for callbacks)
void foo(void *data);
Then if I pass something that is a structure
struct testing {
int a;
char b;
};
int main(void)
{
struct testing x;
x.a = 1;
x.b = 2;
foo((void *)&x);
return 0;
}
is this concept valid? If not, what would be a valid way to achieve
portable results?
Best Regards,
Jason.
Just a clarification of the specification about the C-Standard's
interpretation of pointers.
I know that 'char *' and 'void *' are equivalent and that 'int *' may be
different in representation to 'char *' (but most often there is no
difference on modern compilers/machines).
So if I define a function such as (e.g. often for callbacks)
void foo(void *data);
Then if I pass something that is a structure
struct testing {
int a;
char b;
};
int main(void)
{
struct testing x;
x.a = 1;
x.b = 2;
foo((void *)&x);
return 0;
}
is this concept valid? If not, what would be a valid way to achieve
portable results?
Best Regards,
Jason.