ATT and function declarations
rudolph
rudolph at ecr1.UUCP
Sun Apr 13 02:46:47 AEST 1986
While porting some code to the 3b2 i recieved a compiler error
for some valid C code. This code compiled fine on a plexus SYS3
and an NCR TOWER SYS5. I had a routine that allocated an array of
structures and returned a pointer to it so i declared it as
a function returing a pointer to an array of structures of type foo.
eg:
struct foo {
int who;
int cares;
}
typedef struct foo FOO;
FOO (*get_it())[]; /* compiler likes this */
FOO (*where)[];
int call_it ()
{
where = get_it( 1 ); /* and this */
}
FOO (*get_it ( arg ))[] /* complier complains here */
int arg;
{
if( arg > 0 ){
return (FOO (*)[]) malloc( arg * sizeof (FOO) );
}else{
return (FOO (*)[]) NULL;
}
}
to which the 3b2 compiler said
compiler error: compiler takes sizeof function
and lint says nothing!
even when i typedefed it as in
typedef FOO (*pafoo)[];
and declare the function
pafoo get_it ( arg ) { ... }
it still complains all other combinations of typdefs also failed.
so i had to rewrite it to be FOO *get_it() .... sigh :-(
which is the way most people would do it. My question is what is
so wrong with declaring the function as above that AT&T would gag on it.
_____====== ===__n__n____n_
{_____[____] [#]____________}
___________o-o-o o-o-o~o-o O=O=O=O o-o=\_________________________
Just trying to stay on the right track.
More information about the Comp.lang.c
mailing list