R
ramu
Hi,
Can we assign a function pointer to a data pointer( pointer to
any variable)?
Thanks in Advance
Can we assign a function pointer to a data pointer( pointer to
any variable)?
Thanks in Advance
There is no guarantee that function pointers and data pointers
have the same number of bits. And even if you do make the assignment,
that doesn't mean you can use it to read the code.
x86 memory models on MS-DOS are a good example here: function and
data pointers may be 16 or 32 bits, and all 4 possible combinations
are possible. And actually implemented.
ramu said:Hi,
Can we assign a function pointer to a data pointer( pointer to
any variable)?
Hi,
Can we assign a function pointer to a data pointer( pointer to
any variable)?
Thanks in Advance
If you need to have a generic function pointer, you can cast one type
of function pointer to other.
typedef void (*genPointer)(void);
Here genPointer defines a generic function pointer(you can have any
signature; not necesarrily void parameter and return type).
int foo(int ) {}
/* other things */
genPointer aPointer = foo; /* &foo */
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.