So I have this code (the unnecessary parts omitted):

#include <stdio.h>
#include "scene.h"

int main() {
	while(1);
	
	return 0;
}

And another file in the project called "scene.h".

When I compile, I get these errors:

new types may not be defined in a return type
extraneous 'int' ignored
invalid function declaration

All are talking about line 4.
If I remove line 2, it compiles fine (only because I haven't used anything from this file yet).

Any ideas on how to fix this?

>Any ideas on how to fix this?
Nope. Clearly you have a syntax error in scene.h, but since you didn't post the contents, it's impossible to tell you what's wrong or how to fix it.

It doesn't report any errors in scene.h, but here is the code anyway:

#define RES_X 80
#define RES_Y 50

typedef class SCENE
{
	private:
		char heightMap[RES_X][RES_Y]; // white = highest, black = lowest;
		bool boundaryMask[RES_X][RES_Y]; // white = available; black = unavailable;
	
	public:
		bool loadHeightMap(char *filename)
		{
			FILE *image = fopen(filename, "rb");
			int pixel;
			bool end = false;
			
			for(int x = 0; x < RES_X; x++)
			{
				for(int y = 0; y < RES_Y; y++)
				{
					if(!end)
					{
						pixel = getc(image);
						
						if(pixel == EOF) end = true;
					}
					
					this->heightMap[x][y] = (end) ? 0 : pixel;
				}
			}
			
			fclose(image);
			
			if(end) return false;
			else return true;
		}
		
		bool loadBoundaryMask(char *filename)
		{
			FILE *image = fopen(filename, "rb");
			int pixel;
			bool end = false;
			
			for(int x = 0; x < RES_X; x++)
			{
				for(int y = 0; y < RES_Y; y++)
				{
					if(!end)
					{
						pixel = getc(image);
						
						if(pixel == EOF) end = true;
					}
					
					this->boundaryMask[x][y] = (end) ? 0 : (bool)pixel;
				}
			}
		}
		
		void draw()
		{
			for(int x = 0; x < RES_X; x++)
			{
				for(int y = 0; y < RES_Y; y++)
				{
					if(this->boundaryMask[x][y]) printf("1");
					else printf("0");
				}
			}
		}
}

>It doesn't report any errors in scene.h, but here is the code anyway
Of course it doesn't. The errors don't manifest until the int main() { line. In this case because your typedef doesn't end with a semicolon, and the compiler doesn't check for that. It notices that a typedef followed by int is illegal syntax and marks the bad line as the one with your tag for main.

Ugh! I've been programming c++ for at least a year and I make a n00b mistake like that. Oh well. Thank you so much, I wouldn't have caught that myself.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.