Jump to content
Ian Harris

Array Of Pointers To Structs Bug

Recommended Posts

Using 6.87:

 

 

typedef struct _mystruct {
char thing;
char other_thing[2];
int bigger_thing;
} mystruct;

mystruct a_struct;

mystruct *array_of_mystructs[1] = {
&a_struct,
};

 

BoostC says:

 

error: incompatible types 'mystruct*' and 'unsigned char*'

 

It seems to think everything that's an array is really a char*. So if you do this:

 

typedef struct _mystruct {
char thing;
char other_thing[2];
int bigger_thing;
} mystruct;

mystruct a_struct;

char *array_of_mystructs[1] = {
(char *)&a_struct,
};

 

...it compiles. But is obviously not a desirable workaround, since then you need to typecast everything back to a mystruct.

 

regards

Ian.

Share this post


Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...