Public Group

wierd error

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

Recommended Posts

struct profiles{
char name[30];
contact_info profile_contact_info;
}profile_one;

Brings up error message: two or more data types in declaration of 'profile_one' Help!

Share on other sites
Your compiler might give you that error message if you forgot a semi-colon in a class/struct declaration before your profiles declaration.

Share on other sites
I believe it should be typedef struct, since you put an alternative name at the end.

Share on other sites
Quote:
 Original post by pichuI believe it should be typedef struct, since you put an alternative name at the end.

Quoted for truth.

It's worth noting though that, at least in my opinion, it is heinous to tag instances on the end of the declaration of a struct. It's just plain ugly. I would be filled with ungodly power and smite the man who would leave me code with that sort of thing scattered in it [grin]

Share on other sites
What's a typedef struct?

Share on other sites
// instead of:struct profiles{       char name[30];       address profile_address;       contact_info profile_contact_info;       }profile_one;// use:typedef struct profiles{       char name[30];       address profile_address;       contact_info profile_contact_info;} profile_one;// However, you should really use neither of those, rather:struct profiles{       char name[30];       address profile_address;       contact_info profile_contact_info;};profiles profile_one;

Share on other sites
If I try the one you recommended, it says 'multiple types in one declaration'.

Okay, nevermind, I got it, thanks to all. I had thought that

Struct example{
//elements here
}

didn't need a semicolon after the } if it didn't have instances at the end, so the error was actually in the structs above the 'profiles' struct.

[Edited by - MSalley on August 10, 2005 6:03:51 PM]

• What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 11
• 15
• 11
• 11
• 9
• Forum Statistics

• Total Topics
634151
• Total Posts
3015825
×