langer@rainbow.uchicago.edu (Steve langer) (07/27/90)
I've been having trouble with the MIPS C compiler on a Silicon Graphics 4D/220 (3.2). I think this is slightly different than the (void *) bug that was discussed here recently. The problem is that pointers to functions returning void aren't treated properly. The following program doesn't compile if TYPE is defined to be "void". It works if TYPE is defined to be "int". It compiles (and works!) in both cases on a Sun. #include <stdio.h> #define TYPE void TYPE func() { /* A function */ printf("funk!\n"); } main() { TYPE (*function)(); /* A Pointer to a function */ int test = 1; function = func; if(func == function) (*function)(); /* This line doesn't compile! */ } Here's what the compiler says: rainbow74 >> cc junk.c ccom: Error: junk.c, line 13: operands of == have incompatible types if(func == function) (*function)(); ----------------------^ I get the same thing if I try to use something like void (*f)(), (*g)(); int flag; anotherfunction(flag ? f : g); /* incompatible types for ":" ???? */ Thanks for any advice. Steve (langer@control.uchicago.edu)
davea@quasar.wpd.sgi.com (David B. Anderson) (07/27/90)
In article <1990Jul26.200143.1625@midway.uchicago.edu> langer@rainbow.uchicago.edu (Steve langer) writes: > > I've been having trouble with the MIPS C compiler on a >Silicon Graphics 4D/220 (3.2). I think this is slightly different >than the (void *) bug that was discussed here recently. The No, really the same. >problem is that pointers to functions returning void aren't >treated properly. True in 3.2. >The following program doesn't compile if TYPE is defined to be >"void". It works if TYPE is defined to be "int". It compiles >(and works!) in both cases on a Sun. [stuff deleted] >ccom: Error: junk.c, line 13: operands of == have incompatible types > if(func == function) (*function)(); > ----------------------^ Neither void * _nor_ void work dependably in 3.2. The void type was assigned the same type tag as ``undefined'' internally in ccom, which lead to various peculiar error messages. The problems are fixed in 3.3. In 3.3 ccom ``void'' is assigned its own unique internal type tag. Regards. [ David B. Anderson Silicon Graphics (415)335-1548 davea@sgi.com ] [``What can go wrong?'' --Calvin and Hobbes]