Russel Winder <russel@UCL-CS.ARPA> (02/11/85)
Dear all, Please could someone enlighten me about the following piece of C code. It looks perfectly legal to me and if I replace all instances of void with int then it works as expected. static void test() { printf("Hello there\n"); } static void (*fptr) () = test; main() { (*fptr)(); } The third line gives the error: , line 5: operands of = have incompatible types Russel Winder (russel@ucl-cs) Department of Computer Science University College London Gower Street London WC1E 6BT England
Doug Gwyn (VLD/VMB) <gwyn@BRL-VLD.ARPA> (02/12/85)
Please, folks, when you ask about a mysterious system problem, include information about the version of software etc. E.g., "4.2BSD on a VAX-11/750". Older versions of "pcc", such as those distributed with UNIX System III and 4.2BSD, do not properly handle (void (*)()). If you have one of these systems, then that probably explains why your test code does not compile. You can either fix the compiler or get a new one; I recommend the latter, since there are many other bugs in the older "pcc"s as well.
Ron Natalie <ron@BRL-TGR.ARPA> (02/12/85)
You are using an older version of the compiler that blows its mind over "pointer to function returning void." It probably thinks you are attempting to declare a void pointer. -Ron