c++ - Issues with #includes -


i thought use #pragma once solve problems it's not working.

here issue.

i have agui.h wanted main header includes: it:

#pragma once  /*     header includes required headers     required agui        author: josh */  //standard library (stl)  #include <stdlib.h>   #include <iostream> #include <string> #include <sstream> #include <vector> #include <list> #include <algorithm> #include <queue>  //c runtime #include <cmath>  #include <ctime>  //allegro 5  #include <allegro5/allegro.h> #include <allegro5/allegro5.h> #include <allegro5/allegro_image.h> #include <allegro5/allegro_primitives.h> #include <allegro5/allegro_font.h> #include <allegro5/allegro_ttf.h>  #include "aguibasetypes.h" #include "aguiwidgetbase.h" 

aguibasetypes.h looks this:

#pragma once #include "agui.h" #define aguibitmap allegro_bitmap  /*    header contains classes basic types.    these include:    point,    size,     rectangle,    color    , floating equivalents        author: josh */   //integer point class class aguipoint {     int x;     int y; public:     int getx();     int gety();     void setx(int x);     void sety(int y);     void set(int x, int y);     aguipoint(int x, int y);     aguipoint();     std::string tostring();     std::string xtostring();     std::string ytostring();  };  //floating version of agui point class aguipointf {     float x;     float y; public:     float getx();     float gety();     void setx(float x);     void sety(float y);     void set(float x, float y);     aguipointf(float x, float y);     aguipointf(aguipoint p);     aguipointf();     std::string tostring();     std::string xtostring();     std::string ytostring(); };  //integer rectangle class class aguirectangle {     int x;     int y;     int width;     int height; public:      bool isempty();     int gettop();     int getleft();     int getbottom();     int getright();     aguipoint gettopleft();     aguipoint getbottomright(); };  class aguicolor {     unsigned char r;     unsigned char g;     unsigned char b;     unsigned char a; void verifycolorbounds(); public:     aguicolor(int r, int g, int b, int a);     aguicolor(float r, float g, float b, float a);     aguicolor();     int getr();     int getg();     int getb();     int geta(); }; 

and problematic one, aguiwidgetbase.h

#pragma once #include "agui.h"    /*     base class widgets        author: josh */ class aguiwidgetbase {     //variables     aguicolor tintcolor;     aguicolor fontcolor;     //private methods     void zeromemory();     virtual void onpaint();     virtual void ontintcolorchanged(aguicolor color);     void (*onpaintcallback)(aguirectangle clientrect);     void (*ontintcolorchangedcallback)();   public:     aguiwidgetbase(void);     ~aguiwidgetbase(void);     void paint();     void settintcolor(aguicolor color);     aguicolor getbackcolor(); }; 

the compiler not seeing aguibasetypes aguiwidgetbase. causes

warning 13  warning c4183: 'getbackcolor': missing return type; assumed member function returning 'int' c:\users\josh\documents\visual studio 2008\projects\agui\alleg_5\agui\aguiwidgetbase.h  29 error   2   error c4430: missing type specifier - int assumed. note: c++ not support default-int   c:\users\josh\documents\visual studio 2008\projects\agui\alleg_5\agui\aguiwidgetbase.h  14 error   3   error c4430: missing type specifier - int assumed. note: c++ not support default-int   c:\users\josh\documents\visual studio 2008\projects\agui\alleg_5\agui\aguiwidgetbase.h  14 error   5   error c4430: missing type specifier - int assumed. note: c++ not support default-int   c:\users\josh\documents\visual studio 2008\projects\agui\alleg_5\agui\aguiwidgetbase.h  15 error   6   error c4430: missing type specifier - int assumed. note: c++ not support default-int   c:\users\josh\documents\visual studio 2008\projects\agui\alleg_5\agui\aguiwidgetbase.h  15 error   11  error c4430: missing type specifier - int assumed. note: c++ not support default-int   c:\users\josh\documents\visual studio 2008\projects\agui\alleg_5\agui\aguiwidgetbase.h  29 error   12  error c4430: missing type specifier - int assumed. note: c++ not support default-int   c:\users\josh\documents\visual studio 2008\projects\agui\alleg_5\agui\aguiwidgetbase.h  29 error   1   error c2146: syntax error : missing ';' before identifier 'tintcolor'   c:\users\josh\documents\visual studio 2008\projects\agui\alleg_5\agui\aguiwidgetbase.h  14 error   10  error c2146: syntax error : missing ';' before identifier 'getbackcolor'    c:\users\josh\documents\visual studio 2008\projects\agui\alleg_5\agui\aguiwidgetbase.h  29 error   4   error c2146: syntax error : missing ';' before identifier 'fontcolor'   c:\users\josh\documents\visual studio 2008\projects\agui\alleg_5\agui\aguiwidgetbase.h  15 error   8   error c2061: syntax error : identifier 'aguirectangle'  c:\users\josh\documents\visual studio 2008\projects\agui\alleg_5\agui\aguiwidgetbase.h  20 error   7   error c2061: syntax error : identifier 'aguicolor'  c:\users\josh\documents\visual studio 2008\projects\agui\alleg_5\agui\aguiwidgetbase.h  19 error   9   error c2061: syntax error : identifier 'aguicolor'  c:\users\josh\documents\visual studio 2008\projects\agui\alleg_5\agui\aguiwidgetbase.h  28 

how resolve this? there way want agui.h included everywhere, instead of individual includes can confusing on time?

thanks

#pragma once not guaranteed supported on compilers, use include guards instead. furthermore, have cyclic includes: "agui.h" includes "aguibasetypes.h" , vice versa. that's not way it's meant be.

a global include file might okay reduce boilerplate code in source files, in header files, should include necessary headers, or else problem described.


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -