Ok so i'm trying to put together a simple graphics program, following the nehe gamedev tutorials. I'm currently trying to load in some tga graphics files to memory.
I have a header file that is being called by two separate source files. The header file contains a structure as shown below:
Code:
#ifndef __TGA_H__
#define __TGA_H__
#include <windows.h> // Standard windows header
#include <stdio.h> // Standard I/O header
#include <gl\gl.h> // Header for OpenGL32 library
#include "texture.h"
typedef struct
{
GLubyte Header[12]; // TGA File Header
} TGAHeader;
typedef struct
{
GLubyte header[6]; // First 6 Useful Bytes From The Header
GLuint bytesPerPixel; // Holds Number Of Bytes Per Pixel Used In The TGA File
GLuint imageSize; // Used To Store The Image Size When Setting Aside Ram
GLuint temp; // Temporary Variable
GLuint type;
GLuint Height; //Height of Image
GLuint Width; //Width ofImage
GLuint Bpp; // Bits Per Pixel
} TGA;
TGAHeader tgaheader; // TGA header
TGA tga; // TGA image data
GLubyte uTGAcompare[12] = {0,0,2, 0,0,0,0,0,0,0,0,0}; // Uncompressed TGA Header
GLubyte cTGAcompare[12] = {0,0,10,0,0,0,0,0,0,0,0,0}; // Compressed TGA Header
bool LoadUncompressedTGA(Texture *, char *, FILE *); // Load an Uncompressed file
bool LoadCompressedTGA(Texture *, char *, FILE *); // Load a Compressed file
#endif
When I compile everything I get an error saying that TGA and TGAHeader have been defined twice. I understand that this is because the headers are called twice, and the normal solution is to define the objects/functions within one of the sources and only to declare them in the header. Using Extern in the declaration.
However when I do this I get an error saying that only functions and objects can be declared in this way.
So my question is how do I deal with these structures? How do I define and Declare them so they can be used in two source files?