Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Header linking problem

Status
Not open for further replies.

jsteel

Programmer
Feb 11, 2005
17
0
0
US
When I try and include X.h in another header (Y) I get 102 errors in X.h like:

rror C2061: syntax error : identifier 'UCHAR'
error C2146: syntax error : missing ';' before identifier 'colour'
error C2501: 'localVz' : missing storage-class or type specifiers

But I have already included this header in another one of my files. I tried including and defining the same things in the Y header but that seemed to do nothing.

Im sorry this is so vague but I have no idea why it wont let me include the header, and why would the errors be in X.h when I include it in a header like this

#ifndef CMOVEABLE
#define CMOVEABLE

#include "X.h"

class CMoveable : CObject4D {
public:
CMoveable() { }

Move();
};

#endif

Thanks
 
Everything that X.h uses should either be included before or in X.h. Looks like the file defining UCHAR has not been included. There are three schools of thought here

1) Everything that X.h uses should be in X.h. This means that X.h can appear anywhere and it won't have problems. This is the simplest for maintenance.

2) Everything that X.h uses must be included in the source file before X.h. You have to know the system and a minor change in the dependencies can lead to a large number of files being modified. Great when you start the project but really crap for maintenance. Coders who insist on using this technique don't normally stay round to maintain their own mess.

3) A mix of 1 and 2. Legacy code normally ends up like this.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top