Results 1 to 7 of 7

Thread: Visual Studio: Problems with c/c++

  1. #1
    Junior Member Newbie
    Join Date
    Mar 2003
    Posts
    9

    Visual Studio: Problems with c/c++

    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.

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Oct 2000
    Location
    Fargo, ND
    Posts
    1,753

    Re: Visual Studio: Problems with c/c++

    Posting the top few error messages exactly would be helpful. Without that, there will probably be nobody here able to help you.
    Deiussum
    Software Engineer and OpenGL enthusiast

  3. #3
    Junior Member Newbie
    Join Date
    Mar 2003
    Posts
    9

    Re: Visual Studio: Problems with c/c++

    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 : ')'

  4. #4
    Senior Member OpenGL Pro
    Join Date
    Oct 2000
    Location
    Fargo, ND
    Posts
    1,753

    Re: Visual Studio: Problems with c/c++

    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:

    Code :
    #ifndef __cplusplus
    typedef int bool;
    #endif
    Deiussum
    Software Engineer and OpenGL enthusiast

  5. #5
    Senior Member Regular Contributor
    Join Date
    Feb 2003
    Location
    Westerville, Oh, USA
    Posts
    201

    Re: Visual Studio: Problems with c/c++

    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).]

  6. #6
    Junior Member Newbie
    Join Date
    Mar 2003
    Posts
    9

    Re: Visual Studio: Problems with c/c++

    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.

  7. #7
    Senior Member Regular Contributor
    Join Date
    Feb 2003
    Location
    Westerville, Oh, USA
    Posts
    201

    Re: Visual Studio: Problems with c/c++

    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).]

Similar Threads

  1. OpenGL and Visual Studio 2010 Problems
    By davidbainbridge in forum OpenGL: Windows
    Replies: 5
    Last Post: 08-20-2011, 08:29 AM
  2. Problems compiling under visual studio.net
    By scr1pt in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 11-08-2004, 06:43 AM
  3. Visual Studio 6 problems
    By cr33ch in forum OpenGL: Windows
    Replies: 0
    Last Post: 02-20-2004, 06:10 AM
  4. Having build problems with MS Visual Studio 6
    By in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 08-04-2000, 09:37 AM
  5. OpenGL problems with Visual Studio 6.0 and 3DFX
    By Herr.O in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 02-24-2000, 02:22 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean