PDA

View Full Version : Visual Studio: Problems with c/c++



Hubert
07-18-2003, 04:41 AM
Hi,

I'm writing an OpenGL-API in "c" and got a big problem. I get 100 error messages following a missing ")". The funny thing about this is: when i rename the same file in .cpp it works fine.

I can only guess and tried all ideas that I had, but now I give up.

Can anybody give me any direction where the problem could be from. I can't find a starting point.

Deiussum
07-18-2003, 04:48 AM
Posting the top few error messages exactly would be helpful. Without that, there will probably be nobody here able to help you.

Hubert
07-18-2003, 04:57 AM
Yes,

you are right.

the error occurs in the header first: After this:

#ifndef _STEREOUTILS_H_
# define _STEREOUTILS_H_
# include "myUtils.h"

# ifdef __cplusplus
extern "C" {
# endif

typedef struct
{
VEKTOR_3D Position; VEKTOR_3D up; VEKTOR_3D Richtung;
double fovx;
double Augenabstand;
double Brennweite;
} CAMERA;

//Funktions-Prototypen

// Extern
extern void defaultCamera(CAMERA *camera);
extern void renderWithVerticalParallax( CAMERA camera, void(*render)(void));
extern void renderQuadbuffered( float windowWidth, float windowHeight, CAMERA camera,
double zNear, double zFar, void(*render)(void) );
extern void renderStencildivided( bool rows, float windowWidth, float windowHeight, CAMERA camera,
double zNear, double zFar, void(*render)(void) );
extern void renderRedgreen( float windowWidth, float windowHeight, CAMERA camera,
double zNear, double zFar, void(*render)(void) );

// Intern
VEKTOR_3D berechneBrennpunkt( CAMERA camera );
void initInterlaced( float windowWidth, float windowHeight, bool rows );

The error message is:

d:\temp\Stereo_Demo\stereoUtils.h(26): error C2059: Syntaxfehler : ')'

Deiussum
07-18-2003, 05:25 AM
bool is a primitive type that doesn't exist in C, but does in C++ so that could be the problem. I would have expected that you got an error saying something to that effect, but you only posted one of the error messages so maybe you did but just didn't recognize it for what it was...

Maybe add something like this to the top:




#ifndef __cplusplus
typedef int bool;
#endif

starman
07-18-2003, 05:31 AM
I'm guessing your IDE assumes C compilation with a .c suffix, and C++ compilation with .cpp suffix. There is no "bool" keyword in C, which is why the C compilation is failing (or at least one reason).

Also, I think the "extern" specification on function prototypes is superfluous. I don't think it hurts anything, but I don't think you need it.

[This message has been edited by starman (edited 07-18-2003).]

Hubert
07-18-2003, 05:40 AM
Thanks a lot.

That really helped me, I have been searching and trying for 2 days now.

I knew it had to be a simple problem. The problem was, that the error message got to another position in the source, so I did not realize it was because of the bool-type.

starman
07-18-2003, 05:49 AM
Why not just use C++? You don't have to do OO programming, just simply use it as a "better C"?

[This message has been edited by starman (edited 07-18-2003).]