Board index » cppbuilder » Compile errors after adding a file to Project Manager

Compile errors after adding a file to Project Manager


2003-11-27 12:54:27 AM
cppbuilder71
I am experimenting with OpenGL & using BCB6 I have got most of my code from
nehe.gamedev.net/ His OpenGL Tutorials. I have modified it for my use
and added a function, declaring it in a header file.
The header file is as follows:-
#ifndef File1.h
#define File1.h
GLvoid BuildLists();
#endif
And the function as follows:-
Other include files
#include "File1.h"
-------
Other code
GLuint centre; // Storage for the Display List
-------
-------
GLvoid BuildLists() // Code to create our Display List named centre.
{
centre = glGenLists(1); // Generate one List
glNewList(centre, GL_COMPILE); // named centre
glBegin(GL_POLYGON); // Draw an object at the Laser
centre.
glVertex2f(0.0200f, 0.0500f);
glVertex2f(0.0200f, -.0500f);
glVertex2f(-.0200f, -.0500f);
glVertex2f(-.0200f, 0.0500f);
glEnd(); //
glEndList();
}
Everything works Ok, it compiles and the Display List draws my object.
Now if I remove the function code and place it in a seperate file, (I have
done this by cut and paste from the original & then coded the original out).
As follows:-
#include "File1.h"
GLvoid BuildLists() // Code to create our Display List named centre.
{
centre = glGenLists(1); // Generate one List
glNewList(centre, GL_COMPILE); // named centre
glBegin(GL_POLYGON); // Draw an object at the Laser
centre.
glVertex2f(0.0200f, 0.0500f);
glVertex2f(0.0200f, -.0500f);
glVertex2f(-.0200f, -.0500f);
glVertex2f(-.0200f, 0.0500f);
glEnd(); //
glEndList();
}
I have then added this .cpp file to the Project Manager.
Now when I try to compile the Project I get two error messages:-
[C++ Error] File1.h(4): E2141 Declaration syntax error. This one highlights
the line
GLvoid BuildLists(); in the header file. The second error:-
[C++ Error] File003a.c(5): E2141 Declaration syntax error. Highlights the
line at the start of the function code:-
GLvoid BuildLists()
All my efforts so far have failed to resolve this. I am sure I should be
able to add more .cpp files to the Project.
Hope some of you can enlighten me.
Roger Berrall
 
 

Re:Compile errors after adding a file to Project Manager

I think the compiler doesn't know what a GLvoid is.
In the first example you posted you had,
Quote
Other include files
#include "File1.h"
And in the second example you had,
Quote
#include "File1.h"

GLvoid BuildLists() // Code to create our Display List named centre.
Looks like the "Other include files" contained the definition of GLvoid.
Stew
"Roger Berrall" < XXXX@XXXXX.COM >wrote in message
Quote
I have then added this .cpp file to the Project Manager.
Now when I try to compile the Project I get two error messages:-
[C++ Error] File1.h(4): E2141 Declaration syntax error. This one
highlights
the line
GLvoid BuildLists(); in the header file. The second error:-
[C++ Error] File003a.c(5): E2141 Declaration syntax error. Highlights the
line at the start of the function code:-
GLvoid BuildLists()

All my efforts so far have failed to resolve this. I am sure I should be
able to add more .cpp files to the Project.
Hope some of you can enlighten me.

Roger Berrall





 

Re:Compile errors after adding a file to Project Manager

Thanks Big Stew for your reply.
In the first example I posted there was only one .cpp file this had what I
called Other include files, and then #include "File1.h" - Lets call this
file the main one, now in my second example I have created a new and
additional file, removing the #include "File1.h" from the main.cpp file and
adding it to the newly created .cpp file The Other include files are still
in the main.cpp file and this file plus the File1.cpp are in the Project
Manager.
Just for clarity these are the other include files in main.cpp
#include <vcl.h>
#include <windows.h>// Header file for windows
#include <gl\gl.h>// Header file for the OpenGL32 library
#include <gl\glu.h>// Header file for the GLu32 library
#include <gl\glaux.h>// Header file for the GLaux library
I think GLvoid is defined in the gl.h file
Thanks
Roger Berrall
"Big Stew" < XXXX@XXXXX.COM >wrote in message
Quote
I think the compiler doesn't know what a GLvoid is.

In the first example you posted you had,

>Other include files
>#include "File1.h"

And in the second example you had,

>#include "File1.h"
>
>GLvoid BuildLists() // Code to create our Display List named centre.

Looks like the "Other include files" contained the definition of GLvoid.

Stew

"Roger Berrall" < XXXX@XXXXX.COM >wrote in message
news: XXXX@XXXXX.COM ...
>I have then added this .cpp file to the Project Manager.
>Now when I try to compile the Project I get two error messages:-
>[C++ Error] File1.h(4): E2141 Declaration syntax error. This one
highlights
>the line
>GLvoid BuildLists(); in the header file. The second error:-
>[C++ Error] File003a.c(5): E2141 Declaration syntax error. Highlights
the
>line at the start of the function code:-
>GLvoid BuildLists()
>
>All my efforts so far have failed to resolve this. I am sure I should be
>able to add more .cpp files to the Project.
>Hope some of you can enlighten me.
>
>Roger Berrall
>
>
>
>
>


 

{smallsort}