lyndon@cs.AthabascaU.CA (Lyndon Nerenberg) (11/16/89)
While compiling bash under Ultrix 2.3 I ran across an interesting
piece of C that chokes cc(1) under Ultrix 2.3, but compiles fine
under SunOS3.5 and under Ultrix 2.3 using gcc.
The idea of passing parameters as 'void *mumble' seems a bit
questionable. Is the compiler correct to complain about this?
Can someone try it under 3.1 and let me know what it says?
Here's an example using a simplified version of the code in question.
The real stuff is around line 49 of unwind_prot.c in the bash 1.04
distribution.
Script started on Wed Nov 15 12:56:05 1989
auvax:/nfs/auvax2/lyndon% cat foo.c
typedef int Function () ;
foo(arg0, arg1, arg2)
Function *arg0;
void *arg1, *arg2;
{
(*arg0)(arg1, arg2);
}
auvax:/nfs/auvax2/lyndon% cc -c foo.c
"foo.c", line 7: arg1 undefined
"foo.c", line 7: arg2 undefined
auvax:/nfs/auvax2/lyndon%
script done on Wed Nov 15 12:56:29 1989
--
Lyndon Nerenberg VE6BBM / Computing Services / Athabasca University
{alberta,decwrl,lsuc}!atha!lyndon || lyndon@cs.AthabascaU.CA
The Connector is the Notwork.
karish@forel.stanford.edu (Chuck Karish) (11/16/89)
In article <1239@atha.AthabascaU.CA> lyndon@cs.AthabascaU.CA (Lyndon Nerenberg) wrote: >While compiling bash under Ultrix 2.3 I ran across an interesting >piece of C that chokes cc(1) under Ultrix 2.3, but compiles fine >under SunOS3.5 and under Ultrix 2.3 using gcc. > >The idea of passing parameters as 'void *mumble' seems a bit >questionable. Is the compiler correct to complain about this? >Can someone try it under 3.1 and let me know what it says? `void *' is the correct type for generic storage under ANSI C. malloc(), calloc(), and realloc() return pointers to void. The pointers are normally cast to a specific data type before use. There's nothing wrong with having a function allocate generic storage and pass its address to another function. The Portable C Compiler recognizes void as a pseudo-type, for functions that don't return a value. It does not recognize it as a storage type. gcc supports the ANSI usage. The MIPS C compiler on the DS3100 under 3.1 does not. Chuck Karish karish@mindcraft.com (415) 323-9000 karish@forel.stanford.edu