Unknown error can't find any online explanation

  • (2 Pages)
  • +
  • 1
  • 2

15 Replies - 8084 Views - Last Post: 03 August 2012 - 02:52 AM Rate Topic: -----

#1 lifeinbinary  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 166
  • Joined: 15-February 11

Unknown error can't find any online explanation

Posted 02 August 2012 - 05:35 PM

I'm getting "Expected member name or ; after declaration" error in a .hpp file. I'm following a tutorial in a book to create OpenGL ES app for iPhone. This file was created explicitly with .hpp extension to say it is a pure c++ file (no objective-c). I also get "Unknown type name virtual"... what's going on? Here's the code:

#ifndef Tetronimo_IRenderingEngine_hpp
#define Tetronimo_IRenderingEngine_hpp

// Physical orientation of a handheld device, equivalent to UIDeviceOrientation
enum DeviceOrientation 
{
    DeviceOrientationUnknown,
    DeviceOrientationPortrait,
    DeviceOrientationPortraitUpsideDown,
    DeviceOrientationLandscapeLeft,
    DeviceOrientationLandscapeRight,
    DeviceOrientationFaceUp,
    DeviceOrientationFaceDown,
};

// Creates an instance of the renderer and sets up various OpenGL state.
struct IRenderingEngine* CreateRenderer1();

// Interface to the OpenGL ES renderer; consumed by GLView.
struct IRenderingEngine 
{
    virtual void Initialize(int width, int height) = 0;    
    virtual void Render() const = 0;
    virtual void UpdateAnimation(float timeStep) = 0;
    virtual void OnRotate(DeviceOrientation newOrientation) = 0;
    virtual ~IRenderingEngine() {}
};

#endif



The error is happening in every line in my IRenderingEngine struct.

Thanks!

Is This A Good Question/Topic? 0
  • +

Replies To: Unknown error can't find any online explanation

#2 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 5895
  • View blog
  • Posts: 20,130
  • Joined: 05-May 12

Re: Unknown error can't find any online explanation

Posted 02 August 2012 - 05:41 PM

I think that lines 16-17 should come after the struct definition on lines 19-27.
Was This Post Helpful? 0
  • +
  • -

#3 lifeinbinary  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 166
  • Joined: 15-February 11

Re: Unknown error can't find any online explanation

Posted 02 August 2012 - 05:56 PM

No that did not help :( Anything else?
Was This Post Helpful? 0
  • +
  • -

#4 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 5895
  • View blog
  • Posts: 20,130
  • Joined: 05-May 12

Re: Unknown error can't find any online explanation

Posted 02 August 2012 - 06:08 PM

You should really post the error messages verbatim including line numbers instead of summarizing. Also re-post your code with the line changes.
Was This Post Helpful? 0
  • +
  • -

#5 lifeinbinary  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 166
  • Joined: 15-February 11

Re: Unknown error can't find any online explanation

Posted 02 August 2012 - 06:18 PM

The errors are verbatim:

Expected member name or ';' after declaration specifiers

and

Unknown type name 'virtual'

and

Expected ';' at end of declaration list

These errors happen on lines 22-26.
Was This Post Helpful? 0
  • +
  • -

#6 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 5895
  • View blog
  • Posts: 20,130
  • Joined: 05-May 12

Re: Unknown error can't find any online explanation

Posted 02 August 2012 - 07:30 PM

Can you post the code? I though that you moved lines 16-17 to after lines 19-27? But those errors seem to still point to lines that what you posted on post #1.
Was This Post Helpful? 0
  • +
  • -

#7 lifeinbinary  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 166
  • Joined: 15-February 11

Re: Unknown error can't find any online explanation

Posted 02 August 2012 - 07:53 PM

//
//  IRenderingEngine.hpp
//  Tetronimo
//
//  Created by Sam Thibodeau on 12-08-02.
//  Copyright (c) 2012 Mount Allison. All rights reserved.
//

#ifndef Tetronimo_IRenderingEngine_hpp
#define Tetronimo_IRenderingEngine_hpp

// Physical orientation of a handheld device, equivalent to UIDeviceOrientation
enum DeviceOrientation 
{
    DeviceOrientationUnknown,
    DeviceOrientationPortrait,
    DeviceOrientationPortraitUpsideDown,
    DeviceOrientationLandscapeLeft,
    DeviceOrientationLandscapeRight,
    DeviceOrientationFaceUp,
    DeviceOrientationFaceDown,
};

// Interface to the OpenGL ES renderer; consumed by GLView.
struct IRenderingEngine {
    virtual void Initialize(int width, int height) = 0;    
    virtual void Render() const = 0;
    virtual void UpdateAnimation(float timeStep) = 0;
    virtual void OnRotate(DeviceOrientation newOrientation) = 0;
    virtual ~IRenderingEngine() {}
};

// Creates an instance of the renderer and sets up various OpenGL state.
struct IRenderingEngine* CreateRenderer1();

#endif



Errors on lines 26 - 30
Was This Post Helpful? 0
  • +
  • -

#8 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 5895
  • View blog
  • Posts: 20,130
  • Joined: 05-May 12

Re: Unknown error can't find any online explanation

Posted 02 August 2012 - 08:11 PM

Which compiler?

I'm getting successful builds with VS2010. I've also successfully built with gcc in cygwin. Later I'll try gcc in Ubuntu when I get to a machine with it.
Was This Post Helpful? 0
  • +
  • -

#9 lifeinbinary  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 166
  • Joined: 15-February 11

Re: Unknown error can't find any online explanation

Posted 02 August 2012 - 08:17 PM

Compiling with Xcode 4.3... don't know if it's a proprietary compiler or just gcc...
Was This Post Helpful? 0
  • +
  • -

#10 #define  Icon User is offline

  • Duke of Err
  • member icon

Reputation: 1852
  • View blog
  • Posts: 6,661
  • Joined: 19-February 09

Re: Unknown error can't find any online explanation

Posted 02 August 2012 - 08:27 PM

Does removing the comma at the end of the enum do anything?

21	    DeviceOrientationFaceDown, //<-- remove comma


Was This Post Helpful? 0
  • +
  • -

#11 lifeinbinary  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 166
  • Joined: 15-February 11

Re: Unknown error can't find any online explanation

Posted 02 August 2012 - 08:32 PM

No that didn't work...
Was This Post Helpful? 0
  • +
  • -

#12 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 5895
  • View blog
  • Posts: 20,130
  • Joined: 05-May 12

Re: Unknown error can't find any online explanation

Posted 02 August 2012 - 08:46 PM

Okay, I think I found the problem. Although the header file has a .hpp extension, what is the name of your file that is including the header file. Does it have a .c extension?

XCode uses the Apple LLVM compiler.

Basically the way I found the problem was by going to the LLVM Live demo which lets me play with the LLVM compiler via the browser. Compiling the code from post #7 in C++ mode gives no errors. Compiling the same code in C mode gives the following errors:
/tmp/webcompile/_24397_0.c:26:5: error: unknown type name 'virtual'
    virtual void Initialize(int width, int height) = 0;    
    ^
/tmp/webcompile/_24397_0.c:26:13: error: expected member name or ';' after declaration specifiers
    virtual void Initialize(int width, int height) = 0;    
    ~~~~~~~ ^
/tmp/webcompile/_24397_0.c:26:12: error: expected ';' at end of declaration list
    virtual void Initialize(int width, int height) = 0;    
           ^
           ;
/tmp/webcompile/_24397_0.c:27:5: error: unknown type name 'virtual'
    virtual void Render() const = 0;
    ^
/tmp/webcompile/_24397_0.c:27:13: error: expected member name or ';' after declaration specifiers
    virtual void Render() const = 0;
    ~~~~~~~ ^
/tmp/webcompile/_24397_0.c:27:12: error: expected ';' at end of declaration list
    virtual void Render() const = 0;
           ^
           ;
/tmp/webcompile/_24397_0.c:28:5: error: unknown type name 'virtual'
    virtual void UpdateAnimation(float timeStep) = 0;
    ^
/tmp/webcompile/_24397_0.c:28:13: error: expected member name or ';' after declaration specifiers
    virtual void UpdateAnimation(float timeStep) = 0;
    ~~~~~~~ ^
/tmp/webcompile/_24397_0.c:28:12: error: expected ';' at end of declaration list
    virtual void UpdateAnimation(float timeStep) = 0;
           ^
           ;
/tmp/webcompile/_24397_0.c:29:5: error: unknown type name 'virtual'
    virtual void OnRotate(DeviceOrientation newOrientation) = 0;
    ^
/tmp/webcompile/_24397_0.c:29:13: error: expected member name or ';' after declaration specifiers
    virtual void OnRotate(DeviceOrientation newOrientation) = 0;
    ~~~~~~~ ^
/tmp/webcompile/_24397_0.c:29:12: error: expected ';' at end of declaration list
    virtual void OnRotate(DeviceOrientation newOrientation) = 0;
           ^
           ;
/tmp/webcompile/_24397_0.c:30:5: error: unknown type name 'virtual'
    virtual ~IRenderingEngine() {}
    ^
/tmp/webcompile/_24397_0.c:30:13: error: expected member name or ';' after declaration specifiers
    virtual ~IRenderingEngine() {}
    ~~~~~~~ ^
/tmp/webcompile/_24397_0.c:30:12: error: expected ';' at end of declaration list
    virtual ~IRenderingEngine() {}
           ^
           ;
15 errors generated.


This post has been edited by Skydiver: 02 August 2012 - 08:46 PM

Was This Post Helpful? 1
  • +
  • -

#13 lifeinbinary  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 166
  • Joined: 15-February 11

Re: Unknown error can't find any online explanation

Posted 02 August 2012 - 08:50 PM

Two files include the header file. One is a .cpp and the other is a .m? What should I do to fix this problem?
Was This Post Helpful? 0
  • +
  • -

#14 #define  Icon User is offline

  • Duke of Err
  • member icon

Reputation: 1852
  • View blog
  • Posts: 6,661
  • Joined: 19-February 09

Re: Unknown error can't find any online explanation

Posted 02 August 2012 - 08:51 PM

An old stackoverflow.com post.

Why do I get the error “error: unknown type name 'virtual'” when trying to compile this code?
Was This Post Helpful? 1
  • +
  • -

#15 lifeinbinary  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 166
  • Joined: 15-February 11

Re: Unknown error can't find any online explanation

Posted 02 August 2012 - 08:55 PM

Sorry not .m but another .h... So two includes one from .cpp and the other from .h

Thanks for all your effort! Hope I can fix this :)

View Post#define, on 02 August 2012 - 08:51 PM, said:


Awesome! Thank you so much guys :)
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2