Hello,
so I've come to decide that its time to split up the code of my engine an the sample game I'm building with it. For now I've just had one solution, and one project, with game and engine code simply split up by different folders in Visual Studio. So I've tried to split it up in two different projects to begin with. I've tried to compile the engine as a static libary and link the game against it. This however doesn't seem to work very well, since I'm encountering a serious of errors when buildung the game:
1>c:\work\repo\editor\Rect.h(22): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\work\repo\editor\Rect.h(22): error C2143: syntax error : missing ',' before '&'
1>c:\work\repo\editor\Rect.h(24): error C2065: 'vPoint' : undeclared identifier
1>c:\work\repo\editor\Rect.h(24): error C2228: left of '.x' must have class/struct/union
1> type is ''unknown-type''
1>c:\work\repo\editor\Rect.h(25): error C2065: 'vPoint' : undeclared identifier
1>c:\work\repo\editor\Rect.h(25): error C2228: left of '.y' must have class/struct/union
1> type is ''unknown-type''
1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cmath(28): error C2039: 'acosf' : is not a member of '`global namespace''
This is e.g. Rect.h from my engines project:
#pragma once
#include <Windows.h>
#include "Vector.h"
struct Rect
{
public:
Rect(void)
{
x = 0, y = 0, width = 0, height = 0;
}
Rect(int x, int y, int width, int height)
{
this->x = x, this->y = y, this->width = width, this->height = height;
}
void Set(int x, int y, int width, int height)
{
this->x = x, this->y = y, this->width = width, this->height = height;
}
bool Inside(const Vector2& vPoint) const
{
int distanceX = vPoint.x - x;
int distanceY = vPoint.y - y;
return distanceX >= 0 && distanceX <= width && distanceY >= 0 && distanceY <= height;
}
Rect Merge(const Rect& rect) const
{
int x = max(this->x, rect.x);
int y = max(this->y, rect.y);
int x2 = min(this->x+this->width, rect.x+rect.width);
int y2 = min(this->y+this->height, rect.y+rect.height);
return Rect(x, y, x2-x, y2-y);
}
RECT GetWinRect(void) const
{
RECT r = {x, y, width, height};
return r;
}
int x, y, width, height;
};
With "Vector2", my personal integer vector class, obviously not being defined here. Although everything is working fine when compiling the engine to the lib (well, almost, I'll get to that later).
So do you know what could cause this error? Obviously, if you look at the last error message, not only my classes causes this but also something in the "cmath" header.
I've added "C:\Work\Repo\Editor" where all my .cpp and .h are to include directories for the Game, as well as linked against the .lib file currently located in "C:\Work\Repo\Release\". Anything else that I have to do in order to work with static libs?
Aside from that, I've also noticed that the .lib file generated is huge - 55 Mb, while the application previously built is only about 150 kb in size. Any possible reasons for that, or did I do something wrong? Maybe this is related to my errors...