Re: glibc2.1 programming question
On 24-Jun-99, 13:26 (CDT), Andreas Tille <tille@physik.uni-halle.de> wrote:
> Hello,
>
> under glinc2.0 worked the following:
>
> typedef union {
> char *s;
> int i;
> double d;
> } C_VALUE;
>
> int func(C_VALUE val);
>
> void main(void)
^^^^
<comp.std.c> That should be "int". "void main(<anything>)" is not valid
C.</comp.std.c>
> {
> char *s;
>
> func(s);
> }
Yechh. The compiler is right -- that's why we have prototypes.
Replacing it with func((C_VALUE) s) is no better. Consider what happens
if func() decides to access member d. (Ok, you may know that func()
won't do that. But if it doesn't, why does it take a C_VALUE?)
As our fearless leader said, the code is evil.
Steve
Reply to: