Thread: What is function(void *arg)

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    it is just a general pointer passing to the function, your function should know what is the actual type of the pointer - and cast it apropriatly before accessing the data.

    It is mostly used in the Callbacks, when library is provided with CB address and some context address.
    Library does not need to know the type of the data - so the pointer is stored as void* and supplied to the CB, when it is called from the library code

    the CB - which is part of the application code - knows exactly what is the data type passed as a context and could cast the pointer accordingly
    Last edited by vart; 03-17-2009 at 12:23 PM.
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

Popular pages Recent additions subscribe to a feed

Tags for this Thread