Re: Anonymous structures

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



krishna.vamsi@xxxxxxxxx wrote:

> Can I pass anonymous structures as function arguments, 
> 
> Struct A{ int a; int b};
> 
> F(struct A a)
> {
> }
> 
> Int main()
> {
> 	f({a,b})
> }
> 
> If I can how can I do that ?

No. An anonymous structure has an unknown size, so the compiler cannot
generate code to copy them.

Anonymous structures are only useful as pointer targets, i.e.
"struct A *foo". You can pass around pointers to structures without
knowing the size of the structure, although you can't dereference them.

-- 
Glynn Clements <glynn@xxxxxxxxxxxxxxxxxx>
-
: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Assembler]     [Git]     [Kernel List]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [C Programming]     [Yosemite Campsites]     [Yosemite News]     [GCC Help]

  Powered by Linux