Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site ecr1.UUCP Path: utzoo!hcrvax!ecrhub!ecr1!rudolph From: rudolph@ecr1.UUCP (rudolph) Newsgroups: net.lang.c Subject: ATT and function declarations Message-ID: <196@ecr1.UUCP> Date: Sat, 12-Apr-86 11:46:47 EST Article-I.D.: ecr1.196 Posted: Sat Apr 12 11:46:47 1986 Date-Received: Sun, 13-Apr-86 06:10:22 EST Organization: Emerald City Research Inc., Toronto Lines: 58 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.