About Store Forum Documentation Contact



Post Reply 
Redefinition errors [Resolved]
Author Message
JonathonA Offline
Member

Post: #1
Redefinition errors [Resolved]
Apologies if this has been spoken about before, I did search for it and scan the Wiki but didn't come up with anything.

I am trying to use a slot_type.enum.h (located in Data/Enum folder) header I have created in another header file called Inventory.h (located in Shared folder) but when I try to include it it just churns out loads of redefinition errors.

Now in the Main.h header I have the following and I have added my custom enum.h in the _enums.h file but I still get the errors:

Code:
#include "../data/enum/_enums.h"
#include "../Shared/Main.h"
#include "Inventory.h"

What am I missing?

Errors as follows (this is just a sample of them as it generates them for each header in the code unit it is compiling):

Code:
2>d:\divergence (esenthel)\divergence online\data\enum\slot_type.enum.h(8) : error C2011: 'VALID_SLOT_TYPE' : 'enum' type redefinition
2>        d:\divergence (esenthel)\divergence online\data\enum\slot_type.enum.h(8) : see declaration of 'VALID_SLOT_TYPE'
1>d:\divergence (esenthel)\divergence online\data\enum\slot_type.enum.h(8) : error C2011: 'VALID_SLOT_TYPE' : 'enum' type redefinition
1>        d:\divergence (esenthel)\divergence online\data\enum\slot_type.enum.h(8) : see declaration of 'VALID_SLOT_TYPE'

All I attempted to do was add #include "../data/enum/slot_type.enum.h" to my Shared/Inventory.h code resulting in the above.
(This post was last modified: 03-16-2012 01:30 AM by JonathonA.)
03-16-2012 12:30 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Zervox Offline
Member

Post: #2
RE: #include in headers
Might help if we knew what the errors were :/
03-16-2012 12:33 AM
Find all posts by this user Quote this message in a reply
JonathonA Offline
Member

Post: #3
RE: #include in headers
Errors listed for you now
03-16-2012 12:38 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Zervox Offline
Member

Post: #4
RE: #include in headers
It's because multiple files are including either inventory.h or main.h which includes inventory.h and inventory.h includes _enums.h which makes it be redefined for every file, add _enums.h to stdafx.h or main.h where inventory.cpp will include main.h.
(This post was last modified: 03-16-2012 01:21 AM by Zervox.)
03-16-2012 01:21 AM
Find all posts by this user Quote this message in a reply
JonathonA Offline
Member

Post: #5
RE: #include in headers
Ahh stdafx.h of course! The one header file I didn't think of placing it in.

Thanks Zervox.
03-16-2012 01:30 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply