On 1/15/16, James K. Lowden <jklowden at schemamania.org> wrote: > I spent a fair number of hours scrutinizing xDlSym today, and I'd just > like to confirm my understanding. Despite having worked with C on and > off since the Reagan administration, I was unprepared for > > void (*(*xDlSym)(sqlite3_vfs*,void*, const char *zSymbol))(void);
Yes, you decoded the declaration correctly. The rule in C is that you start with the symbol name ("xDlSym" in this case) and start working your way out, preferring stuff on the right over stuff on the left unless there are parentheses to force the left-hand stuff to be taken first. So in the example above we start with "xDlSym is..." There is stuff to the right of the base symbol, but we have to go to the left due to the inner-most parentheses... "... a pointer to...." Having worked out of the inner-most parentheses, we go back to the right again... "... a function taking parameters sqlite3_vfs*, void*, and const char* and returning..." Now there is another set of parentheses which forces us to stop moving right to go to the left again... "... a pointer to..." Now back to the right... "... a function taking no parameters and returning..." And finally once more back to the left: "... void." > > IIUC xDlSym is a pointer to a function taking 3 arguments, returning a > pointer to a "a function", as it says in src/os_unix.c. That function > has a peculiar signature, > > void f(void); > > You may imagine my resistance. That's one function I'm sure I've never > needed, nor ever will! :-) > > The comments also indicate that this definition was created to satisfy > gcc under C90 in pedantic mode. That suggests that once upon a time > xDlSym would have been defined more conventionally as > > void * (*xDlSym)(sqlite3_vfs*,void*, const char *zSymbol); > > but for the never-a-function-pointer-a-void*-shall-be rule of C? > > BTW, cdecl.org offers its own interpretation: > > "declare xDlSym as pointer to function (pointer to void, pointer > to void, pointer to const char) returning pointer to function (void) > returning void" > > which, for me at least, is one of those answers that makes sense only > after you know the answer. > > --jkl > _______________________________________________ > sqlite-users mailing list > sqlite-users at mailinglists.sqlite.org > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users > -- D. Richard Hipp drh at sqlite.org