Advertisement

Frustrating Errors on compile

Started by March 10, 2003 10:26 PM
21 comments, last by adam17 21 years, 11 months ago
1. Post some errors (so we know which classes)
I can''t understand it:
anyway all of the files in my program are included in one file main.h. all of the header files that i created are included at the very end (of main.h?). if i include them at the end of main.h i get the unresolved externals (the other headers?). if i include main.h in the files i made i get at least 100 errors telling me variables are being redefined.
(if ive understood that i can post some things )
2. NEVER define variables in header files!!!!
(define them in source files and declare them as extern (=extern int nVar) in a header file)
3. Write

  #ifndef __HEADER_H__#define __HEADER_H__// HERE the header!!!!#endif  

__HEADER_H__ must be another for each header
(for example __MAIN_H__ for main.h and __MESH_H__ for mesh.h)

or if you dont want to be portable () write #pragma once at the beginning of each header...

But i cant understand the second question ()
Hope this helps



PM


Times change...


Excuse my poor english!
PM Times change... Excuse my poor english!
okay here is the .h header file. at the end of main.h i have included the following file #include "import.h"

    //#include "main.h"#ifndef	IMPORT_H#define IMPORT_Hstruct	RGB{	float r, g, b;};struct	LAYER{	apstring	Name,				Class,				Location,				Filter;	int			Subno,				Noise_level;	float		Amount,				Angle,				Blur,				Blur_offset,				Noise_amt,				Noise_size,				Noise_phase;	POINT		Offset,				Tiling;};struct	MATERIAL{	int			Mat_ID;	apstring	Mat_name,				Mat_file;	RGB			rgb_Ambient,				rgb_Diffuse,				rgb_Specular;	float		Transparency;};struct	MESH{	int			num_vertex,				num_faces,				num_t_vertex,	//number of textured vertices				mat_id;	Vector3		vertex[3125];		//holds xyz values for vertices	Vector3		face[3125];			//holds 3 values for triangle vertices	Vector3		dir[3125];			//holds 3 values for winding polygon	Vector3		fnormal[3125];		//holds 3 values for face normals	Vector3		vnormal[3125];		//holds 3 values for vertex normals};#endif  


and here are the errors i getting

        --------------------Configuration: OpenGL Window - Win32 Release--------------------Compiling...main.cppG:\Adam\Software\Visual C++\OGL Window 2\main.cpp(87) : error C2065: 'Import' : undeclared identifierG:\Adam\Software\Visual C++\OGL Window 2\main.cpp(417) : error C2065: 'map' : undeclared identifierimport.cppG:\Adam\Software\Visual C++\OGL Window 2\import.h(12) : error C2146: syntax error : missing ';' before identifier 'Name'G:\Adam\Software\Visual C++\OGL Window 2\import.h(12) : error C2501: 'apstring' : missing storage-class or type specifiersG:\Adam\Software\Visual C++\OGL Window 2\import.h(12) : error C2501: 'Name' : missing storage-class or type specifiersG:\Adam\Software\Visual C++\OGL Window 2\import.h(13) : error C2501: 'Class' : missing storage-class or type specifiersG:\Adam\Software\Visual C++\OGL Window 2\import.h(14) : error C2501: 'Location' : missing storage-class or type specifiersG:\Adam\Software\Visual C++\OGL Window 2\import.h(15) : error C2501: 'Filter' : missing storage-class or type specifiersG:\Adam\Software\Visual C++\OGL Window 2\import.h(25) : error C2146: syntax error : missing ';' before identifier 'Offset'G:\Adam\Software\Visual C++\OGL Window 2\import.h(25) : error C2501: 'POINT' : missing storage-class or type specifiersG:\Adam\Software\Visual C++\OGL Window 2\import.h(25) : error C2501: 'Offset' : missing storage-class or type specifiersG:\Adam\Software\Visual C++\OGL Window 2\import.h(26) : error C2501: 'Tiling' : missing storage-class or type specifiersG:\Adam\Software\Visual C++\OGL Window 2\import.h(32) : error C2146: syntax error : missing ';' before identifier 'Mat_name'G:\Adam\Software\Visual C++\OGL Window 2\import.h(32) : error C2501: 'apstring' : missing storage-class or type specifiersG:\Adam\Software\Visual C++\OGL Window 2\import.h(32) : error C2501: 'Mat_name' : missing storage-class or type specifiersG:\Adam\Software\Visual C++\OGL Window 2\import.h(33) : error C2501: 'Mat_file' : missing storage-class or type specifiersG:\Adam\Software\Visual C++\OGL Window 2\import.h(46) : error C2146: syntax error : missing ';' before identifier 'vertex'G:\Adam\Software\Visual C++\OGL Window 2\import.h(46) : error C2501: 'Vector3' : missing storage-class or type specifiersG:\Adam\Software\Visual C++\OGL Window 2\import.h(46) : error C2501: 'vertex' : missing storage-class or type specifiersG:\Adam\Software\Visual C++\OGL Window 2\import.h(47) : error C2146: syntax error : missing ';' before identifier 'face'G:\Adam\Software\Visual C++\OGL Window 2\import.h(47) : error C2501: 'Vector3' : missing storage-class or type specifiersG:\Adam\Software\Visual C++\OGL Window 2\import.h(47) : error C2501: 'face' : missing storage-class or type specifiersG:\Adam\Software\Visual C++\OGL Window 2\import.h(48) : error C2146: syntax error : missing ';' before identifier 'dir'G:\Adam\Software\Visual C++\OGL Window 2\import.h(48) : error C2501: 'Vector3' : missing storage-class or type specifiersG:\Adam\Software\Visual C++\OGL Window 2\import.h(48) : error C2501: 'dir' : missing storage-class or type specifiersG:\Adam\Software\Visual C++\OGL Window 2\import.h(49) : error C2146: syntax error : missing ';' before identifier 'fnormal'G:\Adam\Software\Visual C++\OGL Window 2\import.h(49) : error C2501: 'Vector3' : missing storage-class or type specifiersG:\Adam\Software\Visual C++\OGL Window 2\import.h(49) : error C2501: 'fnormal' : missing storage-class or type specifiersG:\Adam\Software\Visual C++\OGL Window 2\import.h(50) : error C2146: syntax error : missing ';' before identifier 'vnormal'G:\Adam\Software\Visual C++\OGL Window 2\import.h(50) : error C2501: 'Vector3' : missing storage-class or type specifiersG:\Adam\Software\Visual C++\OGL Window 2\import.h(50) : error C2501: 'vnormal' : missing storage-class or type specifiersG:\Adam\Software\Visual C++\OGL Window 2\import.cpp(6) : error C2146: syntax error : missing ';' before identifier 'map'G:\Adam\Software\Visual C++\OGL Window 2\import.cpp(6) : error C2501: 'GLuint' : missing storage-class or type specifiersG:\Adam\Software\Visual C++\OGL Window 2\import.cpp(6) : fatal error C1004: unexpected end of file foundError executing cl.exe.OpenGL Window.exe - 34 error(s), 0 warning(s)    


now if you scroll through the errors the classes apstring, POINT, Vector3 (its basically a class that holds an x, y, and z value for vertices), and GLuint do not link during compile. in main.h i have included all of the source files i will need like windows.h and iostream.h etc. int, float, double and all of those basic data types WILL pass through. in case you are not familiar with apstring go to http://www.studio-ide.com/downloads/usingvc/AP.html. any ideas?

[edited by - adam17 on March 16, 2003 12:23:52 PM]
Advertisement
''missing storage-class or type specifiers''
is normaly a .h error...
I think your problem is:
For example: in main.h you have written at the end:

#include "mesh.h" // Declares class CMesh
#include "vector.h" // Declares class CVector

When mesh.h uses the CVector class, you will get a missing storage-class or type specifier error. Thats because the compiler doesnt know CVector when he compiles mesh.h...
When you swap the files in my example, the program should work...
But when youre using mesh.h in vector.h, you HAVE to include mesh.h in vector.h...
when the #ifndef...#define...#endif block is there, there should be no redefinition errors...

Hope this helps



PM


Times change...


Excuse my poor english!
PM Times change... Excuse my poor english!

This topic is closed to new replies.

Advertisement