Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

ddungum

Initializing structure which includes union member

This topic is 5738 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a structure like this : 
ex)   struct BltInfo
      {
	bool bUseColor; 
	union
	{
		long color; 
		struct
		{
			char* imageFilePath; 
			void* pImageCookie; 
		}; 
	}; 
      }; 

and I wanna declare some instances of this structure and initialize them like this : 
ex)      BltInfo bltInfos[] = 
	{
		{false, "resource.jpg", NULL}, 
		{true, 255}
	}; 


But VC++ complain that "cannot convert from 'char [13]' to 'long'". How am I suppose to do to declare and initialize them?
[edited by - ddungum on March 31, 2003 9:09:57 PM]

Share this post


Link to post
Share on other sites
Advertisement
You need to pass a pointer to a memory location. Try:

char name[]="resource.jpg";
BltInfo bltInfos[] = {
{false, name, NULL},
{true, 255}
};



First make it work,
then make it fast.

--Brian Kernighan

"I’m happy to share what I can, because I’m in it for the love of programming. The Ferraris are just gravy, honest!" --John Carmack: Forward to Graphics Programming Black Book

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!