Re: Using initializer without a cast?

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

 



Hi!

On Mon, Apr 09, 2018 at 11:46:09PM +0200, Bostjan Mihoric wrote:
> 	// These require a cast.
> 	mit1 = (MyItemType){ 1.0 };
> 	mit2 = (MyItemType){ .d = 1.0 };
> 	Fun1((MyItemType){ 1.0 });
> 	Fun1((MyItemType){ .d = 1.0 });

Those aren't casts, those are compound literals.

> Is there a way of doing initializers in second group without doing a cast?
> Why can't GCC assume the type just like above?

Because that's not how C works.  Sorry.

(This is not a question about GCC but about C, and so it is off-topic
for this list).


Segher



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux