expected class name before '{' token
-
Hi,
ich hab ein Problem mit meinem Code, der Fehler ist wie folgt:
View_3d.h:45: error: expected class-name before ‘{’ token
hier ist View_3d.h:
[Code/]
#ifndef VIEW3DHFILE
#define VIEW3DHFILE#include "/Users/praktikant/Desktop/wxMac-2.8.10/include/wx/wx.h"
//#include "wx/glcanvas.h"
#include "/Users/praktikant/Desktop/wxMac-2.8.10/include/wx/mac/classic/glcanvas.h"
#include "Palette.h"
#include "Multi_Grid_View.h"
#include "Connect_Adjacent_Points.h"
#include "Trackball.h"
#include "Grid_Vertex_Selection.h"
#include "Zoom.h"class View_3d;
class Tissue;// defines the callback interface for an owner of a 3d view
class View_3d_Holder
{
public:
virtual void view_3d_rotation(View_3d * view) { };
};class View_3d : public wxGLCanvas
{
DECLARE_EVENT_TABLE()
public:
View_3d(wxWindow * parent);
virtual ~View_3d();void create(const Tissue *, View_3d_Holder *);
virtual void render();
void update();
void set_palette(const CancerSim::Palette& p) { m_cell_view.set_palette(p); };
const CancerSim::Palette & palette() const { return m_cell_view.palette(); };
void copy_view_angle(const View_3d &);void OnPaint(wxPaintEvent&);
void OnSize(wxSizeEvent&);
void OnEraseBackground(wxEraseEvent&);
void OnMouseEvent(wxMouseEvent &);protected:
const Tissue * m_tissue;
Multi_Grid_View m_cell_view;
Connect_Adjacent_Points m_capillary_view;
Trackball m_trackball;
Grid_Vertex_Selection m_cell_selection;
Zoom m_zoom;
View_3d_Holder * m_holder;
std::vector<bool> m_cell_visibility;
int m_mouse_y_offset;
int m_mouse_x;
int m_mouse_y;
int m_width;
int m_height;bool some_cells_are_visible() const;
bool m_first_time;
};#endif
[/Code]und glcanvas.h:
[Code/]
#ifndef _WX_GLCANVAS_H_
#define _WX_GLCANVAS_H_#include "wx/defs.h"
#if wxUSE_GLCANVAS
#include "wx/palette.h"
#include "wx/scrolwin.h"
#include "wx/app.h"#ifdef __DARWIN__
# include <OpenGL/gl.h>
# include <AGL/agl.h>
#else
# include <gl.h>
# include <agl.h>
#endifclass WXDLLEXPORT wxGLCanvas; /* forward reference */
class WXDLLEXPORT wxGLContext: public wxObject
{
public:
wxGLContext(AGLPixelFormat fmt, wxGLCanvas *win,
const wxPalette& WXUNUSED(palette),
const wxGLContext *other /* for sharing display lists */
);
virtual ~wxGLContext();void SetCurrent();
void Update(); // must be called after window drag/grows/zoom or clut change
void SetColour(const wxChar *colour);
void SwapBuffers();inline wxWindow* GetWindow() const { return m_window; }
inline HIViewRef aglGetHIViewRef() const { return m_drawable; }public:
AGLContext m_glContext;
HIViewRef m_drawable;
wxWindow* m_window;
};class WXDLLEXPORT wxGLCanvas: public wxWindow
{
DECLARE_CLASS(wxGLCanvas)
public:
wxGLCanvas(wxWindow *parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0,
const wxString& name = wxT("GLCanvas") , int *attribList = 0, const wxPalette& palette = wxNullPalette);
wxGLCanvas( wxWindow *parent, const wxGLContext *shared,
wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0, const wxString& name = wxT("GLCanvas"),
int *attribList = (int*) NULL, const wxPalette& palette = wxNullPalette );wxGLCanvas( wxWindow *parent, const wxGLCanvas *shared, wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0,
const wxString& name = wxT("GLCanvas"), int *attribList = 0, const wxPalette& palette = wxNullPalette );virtual ~wxGLCanvas();
bool Create(wxWindow *parent, const wxGLContext *shared, wxWindowID id,
const wxPoint& pos, const wxSize& size, long style, const wxString& name,
int *attribList, const wxPalette& palette);void SetCurrent();
void SetColour(const wxChar *colour);
void SwapBuffers();
void UpdateContext();
void SetViewport();
virtual bool Show(bool show = true) ;// Unlike some other platforms, this must get called if you override it.
// It sets the viewport correctly and update the context.
// You shouldn't call glViewport yourself either (use SetViewport if you must reset it.)
void OnSize(wxSizeEvent& event);virtual void MacSuperChangedPosition() ;
virtual void MacTopLevelWindowChangedPosition() ;
virtual void MacSuperShown( bool show ) ;void MacUpdateView() ;
inline wxGLContext* GetContext() const { return m_glContext; }
protected:
wxGLContext* m_glContext;
bool m_macCanvasIsShown ;
DECLARE_EVENT_TABLE()
};#endif // wxUSE_GLCANVAS
#endif // _WX_GLCANVAS_H_
[/Code]Ich hab keine Ahnung, warum er die Klasse wxGLCanvas nicht erkennt.
Es wäre sehr nett, wenn mir dabei jemand helfen könnte!
-
Benutze wenn möglich die [ cpp] [ /cpp] tags. Ich hab das jetzt mal für Dich gemacht.
#ifndef VIEW3DHFILE #define VIEW3DHFILE #include "/Users/praktikant/Desktop/wxMac-2.8.10/include/wx/wx.h" //#include "wx/glcanvas.h" #include "/Users/praktikant/Desktop/wxMac-2.8.10/include/wx/mac/classic/glcanvas.h" #include "Palette.h" #include "Multi_Grid_View.h" #include "Connect_Adjacent_Points.h" #include "Trackball.h" #include "Grid_Vertex_Selection.h" #include "Zoom.h" class View_3d; class Tissue; // defines the callback interface for an owner of a 3d view class View_3d_Holder { public: virtual void view_3d_rotation(View_3d * view) { }; }; class View_3d : public wxGLCanvas { DECLARE_EVENT_TABLE() public: View_3d(wxWindow * parent); virtual ~View_3d(); void create(const Tissue *, View_3d_Holder *); virtual void render(); void update(); void set_palette(const CancerSim::Palette& p) { m_cell_view.set_palette(p); }; const CancerSim::Palette & palette() const { return m_cell_view.palette(); }; void copy_view_angle(const View_3d &); void OnPaint(wxPaintEvent&); void OnSize(wxSizeEvent&); void OnEraseBackground(wxEraseEvent&); void OnMouseEvent(wxMouseEvent &); protected: const Tissue * m_tissue; Multi_Grid_View m_cell_view; Connect_Adjacent_Points m_capillary_view; Trackball m_trackball; Grid_Vertex_Selection m_cell_selection; Zoom m_zoom; View_3d_Holder * m_holder; std::vector<bool> m_cell_visibility; int m_mouse_y_offset; int m_mouse_x; int m_mouse_y; int m_width; int m_height; bool some_cells_are_visible() const; bool m_first_time; }; #endifund glcanvas.h:
#ifndef _WX_GLCANVAS_H_ #define _WX_GLCANVAS_H_ #include "wx/defs.h" #if wxUSE_GLCANVAS #include "wx/palette.h" #include "wx/scrolwin.h" #include "wx/app.h" #ifdef __DARWIN__ # include <OpenGL/gl.h> # include <AGL/agl.h> #else # include <gl.h> # include <agl.h> #endif class WXDLLEXPORT wxGLCanvas; /* forward reference */ class WXDLLEXPORT wxGLContext: public wxObject { public: wxGLContext(AGLPixelFormat fmt, wxGLCanvas *win, const wxPalette& WXUNUSED(palette), const wxGLContext *other /* for sharing display lists */ ); virtual ~wxGLContext(); void SetCurrent(); void Update(); // must be called after window drag/grows/zoom or clut change void SetColour(const wxChar *colour); void SwapBuffers(); inline wxWindow* GetWindow() const { return m_window; } inline HIViewRef aglGetHIViewRef() const { return m_drawable; } public: AGLContext m_glContext; HIViewRef m_drawable; wxWindow* m_window; }; class WXDLLEXPORT wxGLCanvas: public wxWindow { DECLARE_CLASS(wxGLCanvas) public: wxGLCanvas(wxWindow *parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const wxString& name = wxT("GLCanvas") , int *attribList = 0, const wxPalette& palette = wxNullPalette); wxGLCanvas( wxWindow *parent, const wxGLContext *shared, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const wxString& name = wxT("GLCanvas"), int *attribList = (int*) NULL, const wxPalette& palette = wxNullPalette ); wxGLCanvas( wxWindow *parent, const wxGLCanvas *shared, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const wxString& name = wxT("GLCanvas"), int *attribList = 0, const wxPalette& palette = wxNullPalette ); virtual ~wxGLCanvas(); bool Create(wxWindow *parent, const wxGLContext *shared, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name, int *attribList, const wxPalette& palette); void SetCurrent(); void SetColour(const wxChar *colour); void SwapBuffers(); void UpdateContext(); void SetViewport(); virtual bool Show(bool show = true) ; // Unlike some other platforms, this must get called if you override it. // It sets the viewport correctly and update the context. // You shouldn't call glViewport yourself either (use SetViewport if you must reset it.) void OnSize(wxSizeEvent& event); virtual void MacSuperChangedPosition() ; virtual void MacTopLevelWindowChangedPosition() ; virtual void MacSuperShown( bool show ) ; void MacUpdateView() ; inline wxGLContext* GetContext() const { return m_glContext; } protected: wxGLContext* m_glContext; bool m_macCanvasIsShown ; DECLARE_EVENT_TABLE() }; #endif // wxUSE_GLCANVAS #endif // _WX_GLCANVAS_H_
-
Ah sorry, hab ich nicht mitbekommen, danke!
-
New_c++_User schrieb:
Ah sorry, hab ich nicht mitbekommen, danke!
Außerdem hast du wohl den Preview-Button noch nicht entdeckt. Da hättest du sofort erkannt, dass deine code-Tags mistig sind.
Frage:
Entspricht hier Zeile 45 auch der Zeile 45 im tatsächlichen Code?
Poste mehr von der Fehlermeldung, am besten von der letzten ordentlich kompilierten Datei bis zum Ende der Fehlermeldung. Zeile 45 steht ein "protected". Nix von "{" oder Deklaration eines Members.
-
also es geht um die folgende Zeile:
class View_3d : public wxGLCanvas { //<-- hier DECLARE_EVENT_TABLE() public: View_3d(wxWindow * parent); virtual ~View_3d();und die Fehlermeldung ist diese hier:
maggy:CancerSim praktikant$ make -f makefile2.txt g++ -c -O3 `/Users/praktikant/Desktop/wxMac-2.8.10/build-ansi/wx-config --cxxflags` -c -o GUI.o GUI.cc View_3d.h:45: error: expected class-name before ‘{’ token History_View.h:33: error: expected class-name before ‘{’ token wxGLCanvas2.h:31: error: expected class-name before ‘{’ token make: *** [GUI.o] Error 1
-
Da scheint ja mehr nicht zu passen.
Ich würde dir empfehlen, deine Umgebung ordentlich einzurichten.
Sowas#include "/Users/praktikant/Desktop/wxMac-2.8.10/include/wx/wx.h" //#include "wx/glcanvas.h" #include "/Users/praktikant/Desktop/wxMac-2.8.10/include/wx/mac/classic/glcanvas.h"ist hässlich, nicht portierbar, und im Falle von glcanvas.h hab ich sogar meinen Zweifel, dass das wirklich korrekt ist.
Und außerdem, woher bitte kommt auf einmal das wxGLCanvas2.h?
-
okay, also erstmal hab ich das ganze Programm gar nicht selbst geschrieben, deswegen kenn ich mich nicht so gut damit aus. Zweitens ist dieser Teil
#include "/Users/praktikant/Desktop/wxMac-2.8.10/include/wx/wx.h" //#include "wx/glcanvas.h" #include "/Users/praktikant/Desktop/wxMac-2.8.10/include/wx/mac/classic/glcanvas.h"nicht ganz richtig, der war noch so, weil ich ja schon vorher selbst mal im Internet geguckt hatte, was das alles für eine Ursache haben könnte und da meinte einer, es könnte an nicht genauen Pfaden zu den headers liegen. Also eigentlich steht da:
#include "wx/wx.h" #include "wx/glcanvas.h"Die beiden Dateien wxGLCanvas2.h und History_View.h benutzen auch wxGLCanvas und includieren die selben header-dateien. Sonst noch Fragen?
-
Die wx/glcanvas.h datei ist hier:
#ifndef _WX_GLCANVAS_H_BASE_ #define _WX_GLCANVAS_H_BASE_ #include "wx/defs.h" #if wxUSE_GLCANVAS //--------------------------------------------------------------------------- // Constants for attriblist //--------------------------------------------------------------------------- // The generic GL implementation doesn't support most of these options, // such as stereo, auxiliary buffers, alpha channel, and accum buffer. // Other implementations may actually support them. enum { WX_GL_RGBA=1, /* use true color palette */ WX_GL_BUFFER_SIZE, /* bits for buffer if not WX_GL_RGBA */ WX_GL_LEVEL, /* 0 for main buffer, >0 for overlay, <0 for underlay */ WX_GL_DOUBLEBUFFER, /* use doublebuffer */ WX_GL_STEREO, /* use stereoscopic display */ WX_GL_AUX_BUFFERS, /* number of auxiliary buffers */ WX_GL_MIN_RED, /* use red buffer with most bits (> MIN_RED bits) */ WX_GL_MIN_GREEN, /* use green buffer with most bits (> MIN_GREEN bits) */ WX_GL_MIN_BLUE, /* use blue buffer with most bits (> MIN_BLUE bits) */ WX_GL_MIN_ALPHA, /* use alpha buffer with most bits (> MIN_ALPHA bits) */ WX_GL_DEPTH_SIZE, /* bits for Z-buffer (0,16,32) */ WX_GL_STENCIL_SIZE, /* bits for stencil buffer */ WX_GL_MIN_ACCUM_RED, /* use red accum buffer with most bits (> MIN_ACCUM_RED bits) */ WX_GL_MIN_ACCUM_GREEN, /* use green buffer with most bits (> MIN_ACCUM_GREEN bits) */ WX_GL_MIN_ACCUM_BLUE, /* use blue buffer with most bits (> MIN_ACCUM_BLUE bits) */ WX_GL_MIN_ACCUM_ALPHA /* use alpha buffer with most bits (> MIN_ACCUM_ALPHA bits) */ }; #define wxGLCanvasName _T("GLCanvas") #if defined(__WXMSW__) #include "wx/msw/glcanvas.h" #elif defined(__WXMOTIF__) #include "wx/x11/glcanvas.h" #elif defined(__WXGTK20__) #include "wx/gtk/glcanvas.h" #elif defined(__WXGTK__) #include "wx/gtk1/glcanvas.h" #elif defined(__WXX11__) #include "wx/x11/glcanvas.h" #elif defined(__WXMAC__) #include "wx/mac/glcanvas.h" #elif defined(__WXCOCOA__) #include "wx/cocoa/glcanvas.h" #else #error "wxGLCanvas not supported in this wxWidgets port" #endif #include "wx/app.h" class WXDLLIMPEXP_GL wxGLApp : public wxApp { public: wxGLApp() : wxApp() { } virtual ~wxGLApp(); // use this in the constructor of the user-derived wxGLApp class to // determine if an OpenGL rendering context with these attributes // is available - returns true if so, false if not. bool InitGLVisual(int *attribList); private: DECLARE_DYNAMIC_CLASS(wxGLApp) }; #endif // wxUSE_GLCANVAS #endif // _WX_GLCANVAS_H_BASE_
-
Okay, hat sich erledigt, ich hatte wxWidgets ohne OpenGL ausgeführt.
Sorry, wenn ich irgend jemanden hier gestört habe...