This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Anonymous structure return problem


Hi,


I am trying to compile the following with egcs 2.91.66 (came with some Slackware a while ago):

static struct { int __errcode;  int  __result; }  read_int(int fd)
{
         struct { int __errcode;  int  __result; }  ret;
         return ret;
}

This is of course a dummy code (a template, so to speak), but the problem is that it does not compile. I do not want to declare a typedef for the function's return type, so I define an anonymous structure (the function returns a structure, not a pointer). I am getting "incompatible types in return" compiler error for the line containing "return ret" statement. Why doesn't this work?

Types for ret and for the function are identical as declared.

I would like to avoid explicit declaration of structure type.

Someone also tested the code on gcc 3.2.1 with the same (unsuccessful) result.

--
Dmitry M. Golubovsky
       South Lyon, MI


-- *** Sent from linux-users at lugwash dot org *** http://www.lugwash.org to unsubscribe: `echo "unsubscribe" | mail linux-users-request at lugwash dot org`


-- Dmitry M. Golubovsky South Lyon, MI



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]