Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Can a void pointer be used to hold a function pointer

Reply
Thread Tools

Can a void pointer be used to hold a function pointer

 
 
junky_fellow@yahoo.co.in
Guest
Posts: n/a
 
      08-02-2009
Guys,

Can a function pointer be converted to a void pointer and back
again ? Will the final result compare equal to the original function
pointer ?

thanks..
 
Reply With Quote
 
 
 
 
Kenny McCormack
Guest
Posts: n/a
 
      08-02-2009
In article <(E-Mail Removed)>,
http://www.velocityreviews.com/forums/(E-Mail Removed) <(E-Mail Removed)> wrote:
>Guys,
>
> Can a function pointer be converted to a void pointer and back
>again ? Will the final result compare equal to the original function
>pointer ?


Two answers:

1) I assume you've tested it, and found the answer to be "Yes".

2) So, you must be looking for a standards-based answer, and, as always,
the standards-based answer is "No".

 
Reply With Quote
 
 
 
 
Fred Bloggs
Guest
Posts: n/a
 
      08-06-2009
(E-Mail Removed) (Gordon Burditt) wrote in news:65OdnYe1UKwnv-
(E-Mail Removed)rnetamerica:

>> Can a function pointer be converted to a void pointer and back
>>again ? Will the final result compare equal to the original function
>>pointer ?

>
> The small, large, compact and middle models on MS-DOS (and early
> Windows systems) use all possible combinations of function pointers
> 16/32 bit and data pointers 16/32 bit. If the function pointer is
> 32 bits and the data pointer is 16 bits (I forget if that's "compact"
> or "middle" model) you can't convert back and forth without losing
> information.
>
> The C standard backs this up by not requiring that you can assign from
> a function pointer to a data pointer and back (or vice versa) without
> losing information.
>
>


Note also that not all processors are von Neumann type.
The instruction and data speces are physically separatre on a processor
with Harvard architecture. Thus a pointer to function can never be
manipulated to point to a data object. This is why pointer to functions are
different to pointers to data objects.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
What is the difference between void proba(); and void proba(void); ??? PencoOdStip@gmail.com C++ 1 05-23-2007 07:12 PM
Function pointer to void function and int function Giannis Papadopoulos C Programming 5 09-05-2005 09:06 PM
what is the difference, void func(void) and void fucn() noblesantosh@yahoo.com C Programming 5 07-22-2005 04:38 PM
"void Method()" vs "void Method(void)" Ollej Reemt C++ 7 04-22-2005 03:47 AM
`void **' revisited: void *pop(void **root) Stig Brautaset C Programming 15 10-28-2003 09:03 AM



Advertisments