M
Mantorok Redgormor
I have ran into a problem where I have a struct
that has a member which contains a pointer
to function and is initialized to a function
in the initializer list. With my array of
structs of this type, I have some elements
of this array, thats function pointer member does
not need to be initialized to a function.
I can't simply initialize it to NULL
and I'm not sure if casting NULL(which can
be 0 or (void *)0) to the function pointer type
will work.
If NULL is (void *)0 on some implementations
you would end up with:
(int (*)(unsigned int))(void *)0
is something like that even guaranteed
to work?
I'm not even sure if just plain 0 and casting
it to the function pointer type would work.
Since function pointers might have different
representations than object pointers, it seems
you would end up with implementation-defined
behavior either way.
Has anyone ran into this problem before?
Where portability was a concern to you
and you couldn't rely on implementation-
defined behavior.
that has a member which contains a pointer
to function and is initialized to a function
in the initializer list. With my array of
structs of this type, I have some elements
of this array, thats function pointer member does
not need to be initialized to a function.
I can't simply initialize it to NULL
and I'm not sure if casting NULL(which can
be 0 or (void *)0) to the function pointer type
will work.
If NULL is (void *)0 on some implementations
you would end up with:
(int (*)(unsigned int))(void *)0
is something like that even guaranteed
to work?
I'm not even sure if just plain 0 and casting
it to the function pointer type would work.
Since function pointers might have different
representations than object pointers, it seems
you would end up with implementation-defined
behavior either way.
Has anyone ran into this problem before?
Where portability was a concern to you
and you couldn't rely on implementation-
defined behavior.