Skip to main content
gamedev.net
🔒 Locked 🤖 Godot

C++ preprocessor problem

Started by jake_Ghost Mar 2, 2009 at 8:36 PM 10 replies 1.3k views
Original Post
jake_Ghost
jake_Ghost
I am in the process of compiling a 64bit version of my program. To make things simpler for me, so I don't need to have two different projects, I am trying to use preprocessor directives.

#if defined(BUILD32)
compile x32 version of class; for example cFont32;
#endif

#if defined(BUILD64)
compile x64 version of class; for example cFont64;
#endif

So the project compiles properly with either or defined except during linkage. I get these errors

Linking...
1>cButton.obj : error LNK2001: unresolved external symbol "public: void __thiscall cFont64::RenderBox(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int,int,int,int,float,float,float,int,int)" (?RenderBox@cFont64@@QAEXV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@HHHHMMMHH@Z)
1>cDropList.obj : error LNK2001: unresolved external symbol "public: void __thiscall cFont64::Render(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int,int,float,float,float,int)" (?Render@cFont64@@QAEXV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@HHMMMH@Z)
1>cTextBox.obj : error LNK2001: unresolved external symbol "public: void __thiscall cFont64::RenderBox(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int,int,int,int,float,float,float,int,int,int &,int &)" (?RenderBox@cFont64@@QAEXV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@HHHHMMMHHAAH1@Z)
1>cGhost.obj : error LNK2001: unresolved external symbol "public: void __thiscall cFont64::DeleteDisplayListFont(void)" (?DeleteDisplayListFont@cFont64@@QAEXXZ)
1>cGhost.obj : error LNK2001: unresolved external symbol "public: void __thiscall cFont64::DeleteFTFont(void)" (?DeleteFTFont@cFont64@@QAEXXZ)
1>cGhost.obj : error LNK2001: unresolved external symbol "public: void __thiscall cFont64::SetDisplayListFont(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?SetDisplayListFont@cFont64@@QAEXV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>cGhost.obj : error LNK2001: unresolved external symbol "public: __thiscall cFont64::~cFont64(void)" (??1cFont64@@QAE@XZ)
1>cGhost.obj : error LNK2001: unresolved external symbol "public: __thiscall cFont64::cFont64(void)" (??0cFont64@@QAE@XZ)
1>MainLoop.obj : error LNK2001: unresolved external symbol "public: void __thiscall cFont64::SetFont(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?SetFont@cFont64@@QAEXV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@0@Z)
1>BUILD\Release/Space Shooter - Release.exe : fatal error LNK1120: 9 unresolved externals

What I don't understand is why they are unresolved. Any help would be great, thanks!
Codeka
Codeka
What's inside your #if defined(...)?

And this isn't relevent to your question, but why would you need a different version of a "font" class for 32-bit and 64-bit?
SiCrane
SiCrane
It sounds a lot like your header has the conditional defines properly written, but one or more of your source files doesn't. Without seeing more code it's hard to say definitively.
jake_Ghost
jake_Ghost
cFont.h

#if defined(BUILD32)#ifndef CFONT_H#define CFONT_H#include <windows.h>									// Header File For Windows#include <math.h>										// Math Library Header File#include <stdio.h>										// Header File For Standard Input/Output#include <mmsystem.h>#include <gl\gl.h>										// Header File For The OpenGL32 Library#include <gl\glu.h>										// Header File For The GLu32 Library#include <fstream>#include <sstream>#include <fstream>#include <cctype>#include <iomanip>#include <cmath>#include <iostream>#include <string>#include <vector>#include <FTGL/FTGLBitmapFont.h>#include "AGT.h"#include "Texture/BMPLoader.h"#define MAX_FONTS 2enum {FONT_LEFT = 0,	  FONT_RIGHT,	  FONT_CENTRE};enum {FONT_FTGL = 0,	  FONT_BITMAP};class	Font{public:	GLuint	base;				// Base Display List For The Font	GLuint	loop;				// Generic Loop Variable	GLfloat	cnt1;				// 1st Counter Used To Move Text & For Coloring	GLfloat	cnt2;				// 2nd Counter Used To Move Text & For Coloring	public:		TGATex textur;	BMPClass bmp;	void Print_scale(GLint x, GLint y, char * string, int set,float scale_x,float scale_y);	void Print_xy_scale(GLint x, GLint y,std::string string, int set,float scale_x,float scale_y);	void Print_xy_rot(GLint x, GLint y, std::string string, int set,float uhol,float scale);	void Print_xy(GLint x, GLint y, std::string string, int set);	Font(std::string file_name, int *error);	~Font(void);	GLvoid glPrint_xy(GLint x, GLint y, char *string, int set);		// pise na OpenGL suradnice x,y	GLvoid glPrint(GLint x, GLint y, char *string, int set);		// pise na y riadok a x stlpec		// funkcie Begin a End treba pouzivat v paroch !!!!	void Begin(void);			// nastavi vsetko potrebne pre pisenie pomocou Print	void Print(GLint x, GLint y, char *string, int set);	// pisanie	void End(void);				// vypne vsetko co sa zaplo pre pisenie pomocou Print};	class cFont{public:	cFont();	~cFont();	void SetFont(std::string Filename, std::string BMPFont);	void SetDisplayListFont(std::string BMPFont);	void DeleteFTFont();	void DeleteDisplayListFont();	void Render(std::string strText, int x, int y, float R, float G, float B, int FaceSize);	void RenderBox(std::string strText, int x, int y, int width, int height, float R, float G, float B, int FaceSize, int Position);	void RenderBox(std::string strText, int x, int y, int width, int height, float R, float G, float B, int FaceSize, int Position, int &newX, int &newY);	void RenderBox(std::string strText, int x, int y, int width, int height, int FaceSize, int Position, int &newX, int &newY);	void SetFontType(int Font) { FontType = Font; }	void SetFontType();	FTFont *font[51];	Font *f;	int FontType;private:	float boxx;	float boxy;	float boxz;	float boxx2;	float boxy2;	float boxz2;	float fSize;	int length;};#endif#endif


#if defined(BUILD32)#include <windows.h>									// Header File For Windows#include <math.h>										// Math Library Header File#include <stdio.h>										// Header File For Standard Input/Output#include <gl\gl.h>										// Header Game For The OpenGL32 Library#include <gl\glu.h>	#include "Font\cFont.h"#include "Texture\TGA.h"#include "cGhost.h"Font::Font(std::string file_name, int *error)					// Build Our Font Display List{	float	cx;											// Holds Our X Character Coord	float	cy;											// Holds Our Y Character Coord	base = 0;	if(!Ghost->Texture->TGA->LoadGLTextures(file_name, TGA_NEAREST))	{		*error = 1;		return;	}	textur = Ghost->Texture->TGA->TGATexture[Ghost->Texture->TGA->GetTexNum(file_name)];	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);							glLoadIdentity();	base=glGenLists(256);								// Creating 256 Display Lists	for (loop=0; loop<256; ++loop)						// Loop Through All 256 Lists	{		cx=float(loop%16)/16.0f;						// X Position Of Current Character		cy=float(loop/16)/16.0f;						// Y Position Of Current Character		glNewList(base+loop,GL_COMPILE);				// Start Building A List		glBindTexture(GL_TEXTURE_2D, textur.imageDataNear);			// Select Our Font Texture			glBegin(GL_QUADS);							                     // Use A Quad For Each Character				glTexCoord2f(cx,1.0f-cy);		            glVertex2i(0,0);   																					glTexCoord2f(cx+0.0625f,1.0f-cy);           glVertex2i(16,0);  																					glTexCoord2f(cx+0.0625f,1.0f-cy-0.0625f);   glVertex2i(16,16); 																				glTexCoord2f(cx,1.0f-cy-0.0625f);		    glVertex2i(0,16);																					glEnd();									                     // Done Building Our Quad (Character)			glTranslatef(10,0,0);	//10,0,0			// Move To The Right Of The Character		glEndList();									// Done Building The Display List	}													// Loop Until All 256 Are Built}Font::~Font(GLvoid)										// Delete The Font From Memory{	glDeleteLists(base,256);							// Delete All 256 Display Lists}GLvoid Font::glPrint_xy(GLint x, GLint y, char *string, int set)	// Where The Printing Happens{	if (set>1)set=1;	glBindTexture(GL_TEXTURE_2D, textur.imageDataNear);		// Select Our Font Texture	glPushMatrix();										// Store The Modelview Matrix	glTranslated(x,y,0);								// Position The Text (0,0 - Bottom Left)	glListBase(base-32+(128*set));						// Choose The Font Set (0 or 1)	glCallLists(strlen(string),GL_BYTE,string);			// Write The Text To The Screen	glPopMatrix();										// Restore The Old Projection Matrix}GLvoid Font::glPrint(GLint x, GLint y, char *string, int set)	// Where The Printing Happens{}void Font::Begin(){}void Font::End(){}void Font::Print(GLint x, GLint y, char * string, int set){}void Font::Print_scale(GLint x, GLint y, char * string, int set,float scale_x,float scale_y){}void Font::Print_xy(GLint x, GLint y, std::string string, int set){	if (set>1)set=1;	glPushMatrix();		glTranslatef((float)x,(float)y,0);					// Position The Text (0,0 - Bottom Left)		glListBase(base-32+(128*set));						// Choose The Font Set (0 or 1)		glCallLists(string.length(),GL_BYTE,string.c_str());			// Write The Text To The Screen	glPopMatrix();}void Font::Print_xy_scale(GLint x, GLint y, std::string string, int set,float scale_x,float scale_y){	if (set>1)set=1;	glPushMatrix();		glTranslatef((float)x,(float)y,0);					// Position The Text (0,0 - Bottom Left)		glScalef(scale_x,scale_y,1.0f);		glListBase(base-32+(128*set));						// Choose The Font Set (0 or 1)		glCallLists(string.length(),GL_BYTE,string.c_str());			// Write The Text To The Screen	glPopMatrix();}void Font::Print_xy_rot(GLint x, GLint y, std::string string, int set,float uhol,float scale){	if (set>1)set=1;	glTranslatef((float)x,(float)y,0);					// Position The Text (0,0 - Bottom Left)	glRotatef(uhol,0,0,1);	glScalef(scale,1.0f,1.0f);	glListBase(base-32+(128*set));						// Choose The Font Set (0 or 1)	glCallLists(string.length(),GL_BYTE,string.c_str());			// Write The Text To The Screen}cFont :: cFont(){	FontType = FONT_BITMAP;   //FONT_BITMAP; FONT_FTGL;}cFont :: ~cFont(){}void cFont :: SetFont(std::string Filename, std::string BMPFont){	int error;	for (int i = 0; i < 51; ++i)	{		font = new FTGLBitmapFont(Filename.c_str());		font->FaceSize(i);	}		f = new Font(BMPFont, &error);}void cFont :: DeleteFTFont(){	delete [] *font;	delete f;}void cFont :: SetDisplayListFont(std::string BMPFont){	int error;	f = new Font(BMPFont, &error);}void cFont :: DeleteDisplayListFont(){	delete f;}void cFont :: Render(std::string strText, int x, int y, float R, float G, float B, int FaceSize){	fSize = float(FaceSize) / 16;	glColor3f(R, G, B);		if (FontType == FONT_FTGL)	{		glDisable(GL_TEXTURE_2D);		glRasterPos2i(x,y);		font[FaceSize]->Render(strText.c_str());		glEnable(GL_TEXTURE_2D);	}	else if (FontType == FONT_BITMAP)	{		glEnable(GL_BLEND);		f->Print_xy_scale(x, y - FaceSize, strText, 0, fSize, fSize);		glDisable(GL_BLEND);	}	glColor3f(1.0f,1.0f,1.0f);}void cFont :: RenderBox(std::string strText, int x, int y, int width, int height, float R, float G, float B, int FaceSize, int Position){	fSize = float(FaceSize) / 16;	font[FaceSize]->BBox(strText.c_str(), boxx, boxy, boxz, boxx2, boxy2, boxz2);	glColor3f(R, G, B);	if (FontType == FONT_FTGL)	{		glDisable(GL_TEXTURE_2D);		if (Position == FONT_LEFT)		{			x += int(boxx);			y += ((int(height) / 2) + (int(boxy2) / 2));		}		else if (Position == FONT_RIGHT)		{			length = int(boxx2) - int(boxx);			x += width - length;			y += ((height / 2) + (int(boxy2) / 2));		}		else if (Position == FONT_CENTRE)		{			length = int(boxx2) - int(boxx);			x += ((width / 2) - (length / 2));			y += ((height / 2) + (int(boxy2) / 2));		}		glRasterPos2i(x,y);		font[FaceSize]->Render(strText.c_str());		glEnable(GL_TEXTURE_2D);	}	else if (FontType == FONT_BITMAP)	{		glEnable(GL_BLEND);		if (Position == FONT_LEFT)		{			x += int(boxx);			y += ((int(height) / 2) + (int(12*fSize) / 2));		}		else if (Position == FONT_RIGHT)		{			length = strText.length() * (11 * fSize);//int(boxx2) - int(boxx);			x += width - length;			y += ((height / 2) + (int(12*fSize) / 2));		}		else if (Position == FONT_CENTRE)		{			length = strText.length() * (11 * fSize);//int(boxx2) - int(boxx);			x += ((width / 2) - (length / 2));			y += ((height / 2) + (int(12*fSize) / 2));		}		f->Print_xy_scale(x, y - FaceSize, strText, 0, fSize, fSize);		glDisable(GL_BLEND);	}	glColor3f(1.0f,1.0f,1.0f);}void cFont :: RenderBox(std::string strText, int x, int y, int width, int height, float R, float G, float B, int FaceSize, int Position, int &newX, int &newY){	fSize = float(FaceSize) / 16;	font[FaceSize]->BBox(strText.c_str(), boxx, boxy, boxz, boxx2, boxy2, boxz2);	glColor3f(R, G, B);	if (FontType == FONT_FTGL)	{		glDisable(GL_TEXTURE_2D);		if (Position == FONT_LEFT)		{			x += int(boxx);			y += ((int(height) / 2) + (int(boxy2) / 2));		}		else if (Position == FONT_RIGHT)		{			length = int(boxx2) - int(boxx);			x += width - length;			y += ((height / 2) + (int(boxy2) / 2));		}		else if (Position == FONT_CENTRE)		{			length = int(boxx2) - int(boxx);			x += ((width / 2) - (length / 2));			y += ((height / 2) + (int(boxy2) / 2));		}		glRasterPos2i(x,y);		font[FaceSize]->Render(strText.c_str());		glEnable(GL_TEXTURE_2D);	}	else if (FontType == FONT_BITMAP)	{		glEnable(GL_BLEND);				if (Position == FONT_LEFT)		{			x += int(boxx);			y += ((int(height) / 2) + (int(12*fSize) / 2));		}		else if (Position == FONT_RIGHT)		{			length = strText.length() * (11 * fSize);//int(boxx2) - int(boxx);			x += width - length;			y += ((height / 2) + (int(12*fSize) / 2));		}		else if (Position == FONT_CENTRE)		{			length = strText.length() * (11 * fSize);//int(boxx2) - int(boxx);			x += ((width / 2) - (length / 2));			y += ((height / 2) + (int(12*fSize) / 2));		}		f->Print_xy_scale(x, y - FaceSize, strText, 0, fSize, fSize);		glDisable(GL_BLEND);	}	glColor3f(1.0f,1.0f,1.0f);	newX = x;	newY = y;}void cFont :: RenderBox(std::string strText, int x, int y, int width, int height, int FaceSize, int Position, int &newX, int &newY){	font[FaceSize]->BBox(strText.c_str(), boxx, boxy, boxz, boxx2, boxy2, boxz2);	if (FontType == FONT_FTGL)	{		if (Position == FONT_LEFT)		{			x += int(boxx);			y += ((int(height) / 2) + (int(boxy2) / 2));		}		else if (Position == FONT_RIGHT)		{			length = int(boxx2) - int(boxx);			x += width - length;			y += ((height / 2) + (int(boxy2) / 2));		}		else if (Position == FONT_CENTRE)		{			length = int(boxx2) - int(boxx);			x += ((width / 2) - (length / 2));			y += ((height / 2) + (int(boxy2) / 2));		}	}	else if (FontType == FONT_BITMAP)	{		if (Position == FONT_LEFT)		{			x += int(boxx);			y += ((int(height) / 2) + (int(12*fSize) / 2));		}		else if (Position == FONT_RIGHT)		{			length = strText.length() * (11 * fSize);//int(boxx2) - int(boxx);			x += width - length;			y += ((height / 2) + (int(12*fSize) / 2));		}		else if (Position == FONT_CENTRE)		{			length = strText.length() * (11 * fSize);//int(boxx2) - int(boxx);			x += ((width / 2) - (length / 2));			y += ((height / 2) + (int(12*fSize) / 2));		}	}	newX = x;	newY = y;}void cFont :: SetFontType(){	if (FontType + 1 == MAX_FONTS)	{		FontType = 0;	}	else	{		++FontType;	}}#endif


I also use the same preprocessor commands for the source file.
The 64bit file looks similar but is called cFont64.

The reason i need two different fonts is because i use FTGL for the 32 bit version and bitmap fonts for the 64 bit version as FTGL doesnt have any 64bit libraries.

Another thing i forgot to note is that i get the same errors with the 32 bit version. The errors go away when i take away the preprocessor commands
jake_Ghost
jake_Ghost
64bit version

#if defined(BUILD64)#ifndef CFONT64_H#define CFONT64_H#include <windows.h>									// Header File For Windows#include <math.h>										// Math Library Header File#include <stdio.h>										// Header File For Standard Input/Output#include <mmsystem.h>#include <gl\gl.h>										// Header File For The OpenGL32 Library#include <gl\glu.h>										// Header File For The GLu32 Library#include <fstream>#include <sstream>#include <fstream>#include <cctype>#include <iomanip>#include <cmath>#include <iostream>#include <string>#include <vector>#include "AGT.h"#include "GameVars.h"#include "Texture/BMPLoader.h"#define MAX_FONTS 2enum {FONT_LEFT = 0,	  FONT_RIGHT,	  FONT_CENTRE};enum {FONT_FTGL = 0,	  FONT_BITMAP};class	Font64{public:	GLuint	base;				// Base Display List For The Font	GLuint	loop;				// Generic Loop Variable	GLfloat	cnt1;				// 1st Counter Used To Move Text & For Coloring	GLfloat	cnt2;				// 2nd Counter Used To Move Text & For Coloring	public:		TGATex textur;	BMPClass bmp;	void Print_scale(GLint x, GLint y, char * string, int set,float scale_x,float scale_y);	void Print_xy_scale(GLint x, GLint y,std::string string, int set,float scale_x,float scale_y);	void Print_xy_rot(GLint x, GLint y, std::string string, int set,float uhol,float scale);	void Print_xy(GLint x, GLint y, std::string string, int set);	void Font(std::string file_name, int *error);	~Font64(void);	GLvoid glPrint_xy(GLint x, GLint y, char *string, int set);		// pise na OpenGL suradnice x,y	GLvoid glPrint(GLint x, GLint y, char *string, int set);		// pise na y riadok a x stlpec		// funkcie Begin a End treba pouzivat v paroch !!!!	void Begin(void);			// nastavi vsetko potrebne pre pisenie pomocou Print	void Print(GLint x, GLint y, char *string, int set);	// pisanie	void End(void);				// vypne vsetko co sa zaplo pre pisenie pomocou Print};	class cFont64{public:	cFont64();	~cFont64();	void SetFont(std::string Filename, std::string BMPFont);	void SetDisplayListFont(std::string BMPFont);	void DeleteFTFont();	void DeleteDisplayListFont();	void Render(std::string strText, int x, int y, float R, float G, float B, int FaceSize);	void RenderBox(std::string strText, int x, int y, int width, int height, float R, float G, float B, int FaceSize, int Position);	void RenderBox(std::string strText, int x, int y, int width, int height, float R, float G, float B, int FaceSize, int Position, int &newX, int &newY);	void RenderBox(std::string strText, int x, int y, int width, int height, int FaceSize, int Position, int &newX, int &newY);	Font64 *f;	float fSize;	int length;};#endif#endif


#if defined(BUILD64)#include <windows.h>									// Header File For Windows#include <math.h>										// Math Library Header File#include <stdio.h>										// Header File For Standard Input/Output#include "Font\cFont x64.h"#include "Texture\TGA.h"#include "cGhost.h"Font64::Font64(std::string file_name, int *error)					// Build Our Font Display List{	float	cx;											// Holds Our X Character Coord	float	cy;											// Holds Our Y Character Coord	base = 0;	if(!Ghost->Texture->TGA->LoadGLTextures(file_name, TGA_NEAREST))	{		*error = 1;		return;	}	textur = Ghost->Texture->TGA->TGATexture[ctga.GetTexNum(file_name)];	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);							glLoadIdentity();	base=glGenLists(256);								// Creating 256 Display Lists	for (loop=0; loop<256; ++loop)						// Loop Through All 256 Lists	{		cx=float(loop%16)/16.0f;						// X Position Of Current Character		cy=float(loop/16)/16.0f;						// Y Position Of Current Character		glNewList(base+loop,GL_COMPILE);				// Start Building A List		glBindTexture(GL_TEXTURE_2D, textur.imageDataNear);			// Select Our Font Texture			glBegin(GL_QUADS);							                     // Use A Quad For Each Character				glTexCoord2f(cx,1.0f-cy);		            glVertex2i(0,0);   																					glTexCoord2f(cx+0.0625f,1.0f-cy);           glVertex2i(16,0);  																					glTexCoord2f(cx+0.0625f,1.0f-cy-0.0625f);   glVertex2i(16,16); 																				glTexCoord2f(cx,1.0f-cy-0.0625f);		    glVertex2i(0,16);																					glEnd();									                     // Done Building Our Quad (Character)			glTranslatef(10,0,0);	//10,0,0			// Move To The Right Of The Character		glEndList();									// Done Building The Display List	}													// Loop Until All 256 Are Built}Font64::~Font64(GLvoid)										// Delete The Font From Memory{	glDeleteLists(base,256);							// Delete All 256 Display Lists}GLvoid Font64::glPrint_xy(GLint x, GLint y, char *string, int set)	// Where The Printing Happens{	if (set>1)set=1;	glBindTexture(GL_TEXTURE_2D, textur.imageDataNear);		// Select Our Font Texture	glPushMatrix();										// Store The Modelview Matrix	glTranslated(x,y,0);								// Position The Text (0,0 - Bottom Left)	glListBase(base-32+(128*set));						// Choose The Font Set (0 or 1)	glCallLists(strlen(string),GL_BYTE,string);			// Write The Text To The Screen	glPopMatrix();										// Restore The Old Projection Matrix}void Font64::Print_xy(GLint x, GLint y, std::string string, int set){	if (set>1)set=1;	glPushMatrix();		glTranslatef((float)x,(float)y,0);					// Position The Text (0,0 - Bottom Left)		glListBase(base-32+(128*set));						// Choose The Font Set (0 or 1)		glCallLists(string.length(),GL_BYTE,string.c_str());			// Write The Text To The Screen	glPopMatrix();}void Font64::Print_xy_scale(GLint x, GLint y, std::string string, int set,float scale_x,float scale_y){	if (set>1)set=1;	glPushMatrix();		glTranslatef((float)x,(float)y,0);					// Position The Text (0,0 - Bottom Left)		glScalef(scale_x,scale_y,1.0f);		glListBase(base-32+(128*set));						// Choose The Font Set (0 or 1)		glCallLists(string.length(),GL_BYTE,string.c_str());			// Write The Text To The Screen	glPopMatrix();}void Font64::Print_xy_rot(GLint x, GLint y, std::string string, int set,float uhol,float scale){	if (set>1)set=1;	glTranslatef((float)x,(float)y,0);					// Position The Text (0,0 - Bottom Left)	glRotatef(uhol,0,0,1);	glScalef(scale,1.0f,1.0f);	glListBase(base-32+(128*set));						// Choose The Font Set (0 or 1)	glCallLists(string.length(),GL_BYTE,string.c_str());			// Write The Text To The Screen}cFont64 :: cFont64(){	}cFont64 :: ~cFont64(){}void cFont64 :: SetFont(std::string Filename, std::string BMPFont){		int error;	f = new Font(BMPFont, &error);}void cFont64 :: DeleteFTFont(){	delete f;}oid cFont :: SetDisplayListFont(std::string BMPFont){	int error;	f = new Font(BMPFont, &error);}void cFont :: DeleteDisplayListFont(){	delete f;}void cFont64 :: Render(std::string strText, int x, int y, float R, float G, float B, int FaceSize){	fSize = float(FaceSize) / 16;	glColor3f(R, G, B);	glEnable(GL_BLEND);	f->Print_xy_scale(x, y - FaceSize, strText, 0, fSize, fSize);	glDisable(GL_BLEND);	glColor3f(1.0f,1.0f,1.0f);}void cFont64 :: RenderBox(std::string strText, int x, int y, int width, int height, float R, float G, float B, int FaceSize, int Position){	fSize = float(FaceSize) / 16;	glColor3f(R, G, B);	glEnable(GL_BLEND);	if (Position == FONT_LEFT)	{		y += ((int(height) / 2) + (int(12*fSize) / 2));	}	else if (Position == FONT_RIGHT)	{		length = strText.length() * (11 * fSize);		x += width - length;		y += ((height / 2) + (int(12*fSize) / 2));	}	else if (Position == FONT_CENTRE)	{		length = strText.length() * (11 * fSize);		x += ((width / 2) - (length / 2));		y += ((height / 2) + (int(12*fSize) / 2));	}	f->Print_xy_scale(x, y - FaceSize, strText, 0, fSize, fSize);	glDisable(GL_BLEND);	glColor3f(1.0f,1.0f,1.0f);}void cFont64 :: RenderBox(std::string strText, int x, int y, int width, int height, float R, float G, float B, int FaceSize, int Position, int &newX, int &newY){	fSize = float(FaceSize) / 16;	glColor3f(R, G, B);	glEnable(GL_BLEND);		if (Position == FONT_LEFT)	{		y += ((int(height) / 2) + (int(12*fSize) / 2));	}	else if (Position == FONT_RIGHT)	{		length = strText.length() * (11 * fSize);		x += width - length;		y += ((height / 2) + (int(12*fSize) / 2));	}	else if (Position == FONT_CENTRE)	{		length = strText.length() * (11 * fSize);		x += ((width / 2) - (length / 2));		y += ((height / 2) + (int(12*fSize) / 2));	}	f->Print_xy_scale(x, y - FaceSize, strText, 0, fSize, fSize);	glDisable(GL_BLEND);	glColor3f(1.0f,1.0f,1.0f);	newX = x;	newY = y;}void cFont64 :: RenderBox(std::string strText, int x, int y, int width, int height, int FaceSize, int Position, int &newX, int &newY){	fSize = float(FaceSize) / 16;	if (Position == FONT_LEFT)	{		y += ((int(height) / 2) + (int(12*fSize) / 2));	}	else if (Position == FONT_RIGHT)	{		length = strText.length() * (11 * fSize);		x += width - length;		y += ((height / 2) + (int(12*fSize) / 2));	}	else if (Position == FONT_CENTRE)	{		length = strText.length() * (11 * fSize);		x += ((width / 2) - (length / 2));		y += ((height / 2) + (int(12*fSize) / 2));	}	newX = x;	newY = y;}#endif
NotAYakk
NotAYakk
Try:
#if defined(BUILD64)#if defined(BUILD32)int x[0];#endif

and the compliment in the other header file. (note: the int x[0] line is intended to not compile, and do so in a way that tends to generate a clear, simple error message.)

Do it in the .cpp file too while you are at it.

Now build. Do you get errors on that line? If so, either follow the #includes to figure out what was defined wrong, or enable verbose descriptions.

Yet another problem can be stale object files being linked into the project. Does the 32/64 problem happen in a disjoint set of your object files?
jake_Ghost
jake_Ghost
Compiles with the same errors as before with no error on that line. I have also deleted my build directory a many times tonight trying to fix this problem lol. I wish that was the case : (.

Also, i used int x = new int(); for that line
Codeka
Codeka
I didn't look too closely at the files, but it seems OK here. Are you sure BUILD64 and BUILD32 is being correctly specified for all files?

However, I would suggest restructuring your code a bit to make life simpler for you. Basically, the way I would do it is by having a common "font.h" file which implements the common interface that both implementations use, and then just have a separate font_32.cpp and font_64.cpp (or whatever) with the actual implementation. So a 32-bit compile would simply compile font_32.cpp and not font_64.cpp, while a 64-bit build would compile font_64.cpp and not font_32.cpp.

But that's probably going to be a fair bit of work for you [smile]
jake_Ghost
jake_Ghost
Quote:
Original post by Codeka
I didn't look too closely at the files, but it seems OK here. Are you sure BUILD64 and BUILD32 is being correctly specified for all files?

However, I would suggest restructuring your code a bit to make life simpler for you. Basically, the way I would do it is by having a common "font.h" file which implements the common interface that both implementations use, and then just have a separate font_32.cpp and font_64.cpp (or whatever) with the actual implementation. So a 32-bit compile would simply compile font_32.cpp and not font_64.cpp, while a 64-bit build would compile font_64.cpp and not font_32.cpp.

But that's probably going to be a fair bit of work for you [smile]


Lol I see where you are going with this... Luckily I am used to a "fair bit of work" lol. I just restructured my entire program a few days ago :P.

I've never done anything like this before (multi-platfor, ect) so ill probably have to try a few different layouts to find the one that works the best.

Thanks for the help guys :D, time to get this bastard running.

Jake
jake_Ghost
jake_Ghost
So I have fixed the problem thanks to you guys. It seems that every file needs to include the file where BUILD32/64 are defined *before* i check to see if they were defined.
NotAYakk
NotAYakk
But if neither are defined, the header file include should resolve to nothing?
jake_Ghost
jake_Ghost
They were being defined properly. So that wasn't an issue. All I know is that including the file where either build32 or 64 is defined before i used any preprocessor directives fixed the problem.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.