Jump to content
  • Advertisement
Sign in to follow this  
EvilNando

c++ compilation bug

This topic is 2616 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Okay this thing is really starting to get into my nerves....

I have 2 classes

Application and ModuleVideo


my Application class contains an instance of the ModuleVideo, the thing is that sometimes at compile time my compiler tells me that ModuleVideo needs a reference which is strange as I have the proper #include "ModuleVideo.h" at the header of Aplication class

but heres the funny thing:

if I comment the class and recompile (gets me some more errors) and then I uncomment and try to recompile again EVERYTHING WORKS OK

why is this?

Share this post


Link to post
Share on other sites
Advertisement
sounds like you have two problems then:
- a dependency problem, regarding compilation
- a syntax problem too

how do you compile ?
can you show the source files ?

Share this post


Link to post
Share on other sites
Don't paraphrase the compiler's error message. Please copy and paste the exact error message.
Also, what compiler are you using?

Share this post


Link to post
Share on other sites
vs2010

pretty simple stuff





#ifndef APPLICATION_H_
#define APPLICATION_H_

#include "Common.h"
#include "ModuleVideo.h"

class Application
{
public:
// stuff
ModuleVideo module_video;
// more stuff
}

#endif



#ifndef MODULE_VIDEO_H_
#define MODULE_VIDEO_H_

#include "Common.h"

// stuff

#endif




the error:



Error 2 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int ...
Error 3 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int ...
Error 1 error C2146: syntax error : missing ';' before identifier 'module_video' ....

Share this post


Link to post
Share on other sites


if I comment the class and recompile (gets me some more errors) and then I uncomment and try to recompile again EVERYTHING WORKS OK




Try cleaning and rebuilding if that happens. See if if that helps.

Share this post


Link to post
Share on other sites
Now you are not reproducing the full source. We are not psychic - we cannot divine problems in code we cannot see. Does Common.h include either Application.h or ModuleVideo.h, directly or indirectly? What does Common.h have in it?

Share this post


Link to post
Share on other sites
Well what's in "//stuff" ? and in Common.h ?

A good thing in general is to reduce/simplify your *real* code, while still keeping the problem, and then show us the *whole* thing.

Share this post


Link to post
Share on other sites
I will be very impressed if the problem lies on the code Ive omitted honestly

theres no way it should affect the compilation behavior, but what do I know...


#include <SDL.h>

#include <stdio.h>
#include <stdarg.h>
#include <fstream>
#include <sstream>
#include <string>

#include "Application.h"

// APPLICATION ERROR CODES
#define ERR_CODE_NONE 0

#define ERR_CODE_SDL_EVENT 1
#define ERR_CODE_SDL_INIT 2

#define ERR_CODE_MODULE_VIDEO 3
#define ERR_CODE_MODULE_VIDEO_SHADERS 4

#define ERR_CODE_FILE_NOT_FOUND 5
#define ERR_CODE_EMPTY_FILE 6

#endif




#ifndef APPLICATION_H_
#define APPLICATION_H_

#include "Common.h"
#include "ModuleVideo.h"

class Application
{
public:
Application();
~Application();

void Init(void);
int Run(void);
void ProcessEvent(SDL_Event*);

static void ShowMessage(char* msg, ...);

private:

bool is_running;
SDL_Event sdl_event;
int error_code;

ModuleVideo module_video;

};

#endif // APPLICATION_H_





#ifndef MODULE_VIDEO_H_
#define MODULE_VIDEO_H_

#include "Common.h"
#include <GL/glew.h>


#define DEFAULT_WIDTH 800
#define DEFAULT_HEIGHT 600

class ModuleVideo
{

public:
ModuleVideo();
~ModuleVideo();

Uint32 Init(void);
Uint32 Init(Uint32, Uint32);

void StartRender(void);
void EndRender(void);

Uint32 CreateShaderProgram(GLint&, const char*, const char*);

private:

Uint32 LoadShaderFile(const char*, std::string&);

union
{
Uint32 width;
Uint32 height;

} resolution;

SDL_Surface* sdl_surface;

};

#endif

Share this post


Link to post
Share on other sites
Is the first file Common.h ?
If so, it's include guard is broken. After fixing it, I can make the thing compile.
(by the way, why is it including Application.h ?)

Looks like you removed too much code again. It's nice to simplify, so that we don't have to read pages and pages of code, but you have to keep the problem present (just test the simplified version before posting it).
Sometimes this process of simplifying will allow you to find the problem yourself.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!