what difference between void (*xmlhashscanner)(void *payload, void *data, xmlchar *name) , void *xmlhashscanner(void *payload, void *data, xmlchar *name) in c?
why behave differently?
xmlhashscanner user-defined function in library libxml2.
when try redefine function little different prototype: void *xmlhashscanner instead of void (*xmlhashscanner) have following error:
error: ‘xmlhashscanner’ redeclared different kind of symbol void *xmlhashscanner(void *payload, void *data, xmlchar *name) ^ in file included /usr/include/libxml2/libxml/parser.h:18:0, /home/solar/bureau/parser/src/diam_dict.c:12: /usr/include/libxml2/libxml/hash.h:88:16: note: previous declaration of ‘xmlhashscanner’ here typedef void (*xmlhashscanner)(void *payload, void *data, xmlchar *name); i wonder difference between 2 of them.
void (*xmlhashscanner)(void *payload, void *data, xmlchar *name) declares xmlhashscanner pointer function returning void, whereas
void *xmlhashscanner(void *payload, void *data, xmlchar *name) declares xmlhashscanner function returning pointer void.
in both declaration , expression syntax, unary * operator has lower precedence postfix [] subscript , () function call operators, so
t *a[n]; // n-element array of pointer t t (*a)[n]; // pointer n-element array of t t *f(); // f function returning pointer t t (*f)(); // f pointer function returning t
Comments
Post a Comment