• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Missing braces? I don't see where
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Missing braces? I don't see where


  • Subject: Re: Missing braces? I don't see where
  • From: Dan Korn <email@hidden>
  • Date: Tue, 27 Oct 2009 17:24:16 -0500

I might be wrong, but I don't think you can initialize more than one "member" of a union like that in the same way you initialize a struct. How would the compiler know you're initializing an RGBCOMPONENT instead of a CMYKCOMPONENT anyway?

And unless you're really hurting for memory, why use a union at all in a modern app? Just have multiple members, only one of which is valid at any given time. They don't need to all pile on top of each other in memory. Especially since you seem to be compiling C++, which offers much more elegant and safe ways of accomplishing polymorphism, which can made be more memory-efficient than a union as well.

If you want to use low-level C-type constructs without the benefits of C++, check out Objective-C ;^) .

Dan

On Oct 27, 2009, at 4:46 PM, Steve Mills wrote:
struct COLORDATA
{
	COLORSPACE	space;
	bool		useCMYKValues;
	union
	{
		RGBCOMPONENT	rgb;
		CMYKCOMPONENT	cmyk;
		GRAYCOMPONENT	gray;
		XYZCOMPONENT	xyz;
	};
};

/depot/cmyk/creatortech/desktop/mac/C2Mac/../../../semiportlib/ GraphicUIAll.cpp:191:0 /depot/cmyk/creatortech/desktop/mac/ C2Mac/../../../semiportlib/GraphicUIAll.cpp:191: warning: missing braces around initializer for 'PortLib::RGBCOMPONENT'
COLORDATA backgroundColor = { kRGBSpace, false, {0xFFFF, 0xFFFF, 0xFFFF} };

_______________________________________________ Do not post admin requests to the list. They will be ignored. Xcode-users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: Missing braces? I don't see where
      • From: Chris Suter <email@hidden>
References: 
 >Missing braces? I don't see where (From: Steve Mills <email@hidden>)

  • Prev by Date: Re: struct "declared with greater visibility than the type of its field" warning
  • Next by Date: Re: Missing braces? I don't see where
  • Previous by thread: Re: Missing braces? I don't see where
  • Next by thread: Re: Missing braces? I don't see where
  • Index(es):
    • Date
    • Thread