Can a void pointer be used to hold a function pointer

Discussion in 'C Programming' started by junky_fellow@yahoo.co.in, Aug 2, 2009.

  1. Guest

    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..
     
    , Aug 2, 2009
    #1
    1. Advertising

  2. In article <>,
    <> 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".
     
    Kenny McCormack, Aug 2, 2009
    #2
    1. Advertising

  3. Fred Bloggs Guest

    (Gordon Burditt) wrote in news:65OdnYe1UKwnv-
    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.
     
    Fred Bloggs, Aug 6, 2009
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ollej Reemt
    Replies:
    7
    Views:
    602
    Jack Klein
    Apr 22, 2005
  2. Stig Brautaset

    `void **' revisited: void *pop(void **root)

    Stig Brautaset, Oct 25, 2003, in forum: C Programming
    Replies:
    15
    Views:
    837
    The Real OS/2 Guy
    Oct 28, 2003
  3. Replies:
    5
    Views:
    882
    S.Tobias
    Jul 22, 2005
  4. Replies:
    3
    Views:
    389
    Tomás
    May 15, 2006
  5. Replies:
    1
    Views:
    435
    Victor Bazarov
    May 23, 2007
Loading...

Share This Page