'vs2008 near far'에 해당되는 글 1건

  1. 2011.05.14 vs2008 변수명 near far는 오류?
Microsoft/Visual Studio2011. 5. 14. 19:52
openGL 에서 예제를 돌리다가 이상한 에러가 나길래 검색+추적을 해보니...

windows.h 에서 windef.h 를 불러들이는데
#undef far
#undef near
#undef pascal

#define far
#define near
#if (!defined(_MAC)) && ((_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED))
#define pascal __stdcall
#else
#define pascal
#endif
 
아무런 내용없이 far와 near가 선언이 되어 있다.
그런 이유로 변수명이나 함수명등의 용도로 far와 near를 사용할 수 없다.

아래와 같이 변수를 선언하면
 double near, far; 
near와 far는 매크로 프로세서에 의해서
 double ;
로 해석이 되므로 아래와 같은 희한한 에러가 발생한다.

c:\opengl\opengl.cpp(63) : warning C4091: '' : 변수를 선언하지 않으면 'double' 왼쪽은 무시됩니다.
c:\opengl\opengl.cpp(63) : error C2143: 구문 오류 : ';'이(가) ',' 앞에 없습니다.
c:\opengl\opengl.cpp(63) : error C2143: 구문 오류 : ';'이(가) ',' 앞에 없습니다.
 

원래 소스는 아래와 같은데
void frustum_depthoffield(GLdouble left, GLdouble right,
                        GLdouble bottom, GLdouble top,
                        GLdouble near, GLdouble far,
                        GLdouble xoff, GLdouble yoff,
                        GLdouble focus)
{
glFrustum( left-xoff*near/ focus,
right-xoff*near/focus,
top-yoff*near/focus,
bottom-yoff*near/focus,
near,far);

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glTranslatef(-xoff, -yoff, 0.0);
} 

위와 같은 이유로 황당하게 '/' 오류가 난다 -_-
c:\opengl\opengl.cpp(63) : error C2059: 구문 오류 : '/' 

Posted by 구차니