2016-06-11 2 views
1

Windows에서 우분투로 glew_mx 프로젝트를 이식하려고하는데 GLEWContext가 정의되지 않아 항상 오류가 발생합니다.'GLEWContext는 우분투에서 오류가 발생했습니다'오류가 발생했습니다.

error: ‘GLEWContext’ does not name a type 

나는 정말 그나마 리눅스에 GLEWContext이 필요하지만, 그럼에도 불구하고 나는 내 프로젝트를 컴파일하기 위해

GLEWContext* glewGetContext(); 

을 정의 할 필요가 있음을 알고있다. 그래서 전역 GLEWContext를 생성하고 단순히 glewGetContext로 리턴합니다.
내 window.h 코드는 다음과 같습니다

#pragma once 
#define GLEW_MX 
#define GLEW_STATIC 
#include "GL/glew.h" 
#include "GLFW/glfw3.h" 
#define GLM_SWIZZLE 
#include "glm/glm.hpp" 
#include "glm/ext.hpp" 

#ifdef _WIN32 
#define CONTEXT_PREFIX window 
#else 
#define CONTEXT_PREFIX 
#endif 

namespace window 
{ 
    class Window 
    { 
    public: 
     Window() {} 
     ~Window() {} 

     //... 

#ifdef _WIN32 
     static void makeContextCurrent(Window* window_handle); 
#endif 
     static Window* createWindow(int win_width, int win_height, const std::string& title, GLFWmonitor* monitor, Window* share); 

     GLFWwindow* window; 
#ifdef _WIN32 
     GLEWContext* glew_context; 
#endif 
     //... 

    private: 
     //... 
    }; 

    GLEWContext* glewGetContext(); 
#ifdef _WIN32 
    //... 
#else 
    GLEWContext* glew_context; 
#endif 
} 

그리고 window.cpp의 코드는 다음과 같습니다

window.h 의 마지막 두 줄을 컴파일하는 동안 오류가 발생
#ifdef _WIN32 
GLEWContext* window::glewGetContext() 
{ 
    //... 
} 
#else 
GLEWContext* window::glewGetContext() 
{ 
    return glew_context; 
} 
#endif 

많은 도움을 주셔서 감사합니다

답변

1

컴파일러가 Window 클래스를 컴파일하고 GLEWContext* glew_context 행을 얻는 것 같습니다. 그러나 GLEWContext은 정의되지 않을 수 있으므로 forward declaration이 도움이 될 수 있습니다.

Windows에서 우분투로 이식하기 때문에 컴파일러에서 #pragma을 지원하는지 확인해야합니다. 포함 보호를 변경할 수 있습니다.

#ifndef WINDOW_H 
#define WINDOW_H 
// Your code here 
#endif 
관련 문제