By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,406 Members | 1,020 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,406 IT Pros & Developers. It's quick & easy.

inclusion guards

P: 5
Ive seen a thread about it here somewhere and tried doing whats being said in that thread, but still having a problem.

Im using a OpenGL Font Class which i want included in different places. One in opengl.cpp and for now, just menu.h.

Font class (CGLFont.h):
Expand|Select|Wrap|Line Numbers
  1. #ifndef _CGL_
  2. #define _CGL_
  3.  
  4. #define NUM_GLYPHS 256
  5. class CGLFont {
  6. public:
  7. ... a bunch of methods
  8. private:
  9. ... a bunch of methods
  10. };
  11.  
  12. #endif
  13.  
I then include that CGLFont.h into my opengl.cpp file, compiles fine...

But when i try creating a menu.h and include "CGLFont.h" into it and then include "menu.h" into "opengl.cpp", i get a bunch of errors

Expand|Select|Wrap|Line Numbers
  1. CGLFont.h(35) : error C2061: syntax error : identifier 'GLuint'
  2. CGLFont.h(37) : error C2146: syntax error : missing ';' before identifier 'hDC'
  3. CGLFont.h(37) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
  4. CGLFont.h(37) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
  5. CGLFont.h(39) : error C2146: syntax error : missing ';' before identifier 'base'
  6. CGLFont.h(39) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
  7. CGLFont.h(39) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
  8. CGLFont.h(43) : error C2146: syntax error : missing ';' before identifier 'ibase'
  9. CGLFont.h(43) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
  10. CGLFont.h(43) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
  11. CGLFont.h(47) : error C2146: syntax error : missing ';' before identifier 'ubase'
  12. CGLFont.h(47) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
  13. CGLFont.h(47) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
  14. CGLFont.h(51) : error C2146: syntax error : missing ';' before identifier 'bbase'
  15. CGLFont.h(51) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
  16. CGLFont.h(51) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
  17.  
I dont have any clue on whats causing the errors and was hoping someone here could tell me :) - I guess it has something to do with the term "inclution guards".
Jun 2 '07 #1
Share this Question
Share on Google+
3 Replies


weaknessforcats
Expert Mod 5K+
P: 9,197
What does your menu.h look like?
Jun 2 '07 #2

P: 5
zmp
menu.h
#include "CGLFont.h"
typedef struct
{
int entry;
bool enabled;
bool menutog;
bool key;
bool right;
bool up;
bool down;
bool left;
}menus_s;

//================================================== ===================
void FillArea(int x,int y,int w,int h,int r,int g,int b,int a);
void Draw_Menu(int menu_width, int x, int y);
Jun 2 '07 #3

weaknessforcats
Expert Mod 5K+
P: 9,197
menu.h
#include "CGLFont.h"
typedef struct
{
int entry;
bool enabled;
bool menutog;
bool key;
bool right;
bool up;
bool down;
bool left;
}menus_s;

//================================================== ===================
void FillArea(int x,int y,int w,int h,int r,int g,int b,int a);
void Draw_Menu(int menu_width, int x, int y);
No help here but I just noticed this:

CGLFont.h(35) : error C2061: syntax error : identifier 'GLuint'
This is your CGLFont.h:
[quote=zmp]
#ifndef _CGL_
#define _CGL_

#define NUM_GLYPHS 256
class CGLFont {
public:
... a bunch of methods
private:
... a bunch of methods
};

#endif
[/code]

and there's nothing here about Gluint. Hence the error. You must have another CGLFont.h in your vest pocket.
Jun 2 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.