Re: Question about 'C' code and use of "void"

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance




"John Carson" <jcarson_n_o_sp_am_@xxxxxxxxxxxxxxx> wrote in message
news:OL8dCQ6hGHA.4712@xxxxxxxxxxxxxxxxxxxxxxx
It works for function pointers to. Thus

void (*fnptr)(int);

declares a variable called fnptr that is a pointer to a function that
takes an int argument and returns void, whereas

typedef void (*fnptr)(int);

declares a typename called fnptr that is an alias for the type of a
pointer to a function that takes an int argument and returns void.


A typedef can also be used to define a function (not function pointer) type.
Such a typedef can be used to declare (though not define) non-member AND
member functions. You will still need to start the function body definition
without typedef.


.



Relevant Pages

  • Re: Casting function pointers
    ... which accepts generic objects via void pointers, ... I think you intended to typedef 'dict_delete' not 'delete'. ... The delete parameter to dict_new will be converted to be of "pointer ... For dictionaries of more complex objects, though, I might ...
    (comp.lang.c)
  • Re: Pointer Indirection Syntax
    ... we have a need for a pointer to a pointer ... >> to a function returning void and having void parameters. ... >> What is the syntax for declaring a pointer to a pointer ... typedef void; ...
    (comp.lang.c)
  • Re: Trying to Retrieve a List of Active Serial/Com Ports
    ... typedef PVOID HANDLE; ... So HANDLE is a void* or a PVOID, which I would -guess- is just ... HANDLE is probably a pointer. ... trying to store a pointer in an int. ...
    (comp.lang.c)
  • Table of pointers to templated functions
    ... How do I declare a typedef of a pointer to a templated ... template ... void print_name ...
    (comp.lang.cpp)
  • Re: Question about C code and use of "void"
    ... And I'm confused becasue void is, of course, a keyword. ... You are confusing #define syntax with typedef syntax. ... int INT; ... declares a typename called INT that is an alias for int. ...
    (microsoft.public.vc.language)