Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7712161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:33:37+00:00 2026-06-01T01:33:37+00:00

I have a header file named Application.h where I include a header named CollisionHandler.h.

  • 0

I have a header file named Application.h where I include a header named CollisionHandler.h. CollisionHandler includes Application.h, so I get a too many includes error when compiling. To solve this I’ve put the CollisionHandler include between header guards, like this:

#ifndef COLLISION_HANDLER_INCLUDED_H
#define COLLISION_HANDLER_INCLUDED_H
#include "CollisionHandler.h"
#endif

but when I try to use a object of type CollisionHandler (this class is defined in CollisionHandler.h, between header guards) as a member variable of the Application class (which is also defined between header guards in Application.h), I get this error repeated for every file that includes Application.h (5 times or so):

1>c:\users\aitor\documents\visual studio 2008\projects\copter\copter\application.h(19) : error C2143: syntax error : missing ';' before '*'
1>c:\users\aitor\documents\visual studio 2008\projects\copter\copter\application.h(19) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\aitor\documents\visual studio 2008\projects\copter\copter\application.h(19) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

The line 19 is the line where I declare the CollisionHandler object as a member variable.

Here is the code in Application.h (With the relevant lines idented):

#include "Header.h"
#include <stdio.h>
#include "GameCharter.h"
#include <vector>
#include <boost/shared_ptr.hpp>
    #ifndef COLLISION_HANDLER_INCLUDED_H //Here I include
    #define COLLISION_HANDLER_INCLUDED_H //the collision
    #include "CollisionHandler.h"        //handler header
    #endif
using namespace std;
#ifndef APPLICATION_DEFINED_H
#define APPLICATION_DEFINED_H
class LimitsManager;
class ObstacleManager;
class Application
{
public:
         CollisionHandler *handler; //Here I declare the CollisionHandler
    ObstacleManager *obstacleManager;
    LimitsManager *limitsManager;
    vector<boost::shared_ptr<GameChar> > characters;
    vector<int> idsToRemove;
    void gameLoop();
    Application();
    bool idsNeedUpdate;
    bool objectsNeedToRemove;
};
#endif

And this is the code for CollisionHandler.h:

#include "Header.h"
#include "Application.h" 
#include "GameCharter.h"
#include "LimitObstacle.h"
#ifndef COLLISION_HANDLER_H
#define COLLISION_HANDLER_H
class CollisionHandler
{
    Application *app;
public:
    void handleCollisions();
    CollisionHandler()
    {

    }
    CollisionHandler(Application *app);
    bool collidersAreCollidingGeneral(GameChar* char1,GameChar* char2);
    bool collidersAreCollidingSecondary(GameChar* char1,GameChar* char2);
};
#endif

Also, if I use class CollisionHandler; in Application.h and then include CollisionHandler.h in the cpp file, it works

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T01:33:39+00:00Added an answer on June 1, 2026 at 1:33 am

    Including headers cyclically is wrong, even with include guards.

    Try to remove the dependency by using forward declarations where possible.

    If you can’t use forward declarations, your design is flawed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm not totally sure but this looks wrong: I have a header file named
I have a header file like this: #ifndef __GEN_NOTE_MARKERS_TO_DEVELOPERS_HPP__ #define __GEN_NOTE_MARKERS_TO_DEVELOPERS_HPP__ #ifdef _DEBUG //
I have this header file, zeeheader.h, and I wrote some classes in it, I'm
I have a header file. In this header I want to use a map
I have a php file generating XHTML content and I use <?php header('Content-type: application/xhtml+xml');?>
I have a header file, lets say Common.h, that is included in all of
I have a header file variable.h where i declare all my global variable.Then i
I have C header file containing the following type definition: // example.h typedef struct
I have a header file with all the enums listed (#ifndef #define #endif construct
I want to reimplement a library of which I have the header file. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.