我正在使用立体视觉的源代码,它会出错
1> StereoMain.cpp
1>c:\opencv2.2\include\opencv2\highgui\highgui_c.h(171): error C2059: syntax error : 'constant'
1>c:\opencv2.2\include\opencv2\highgui\highgui_c.h(171): error C3805: 'constant': unexpected token, expected either '}' or a ','
1> StereoGrabber.cpp
1>c:\opencv2.2\include\opencv2\flann\logger.h(66): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> e:\program files\microsoft visual studio 10.0\vc\include\stdio.h(234) : see declaration of 'fopen'
1>c:\opencv2.2\include\opencv2\highgui\highgui_c.h(171): error C2059: syntax error : 'constant'
1>c:\opencv2.2\include\opencv2\highgui\highgui_c.h(171): error C3805: 'constant': unexpected token, expected either '}' or a ','
1> StereoFunctions.cpp
1>c:\opencv2.2\include\opencv2\flann\logger.h(66): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> e:\program files\microsoft visual studio 10.0\vc\include\stdio.h(234) : see declaration of 'fopen'
1>c:\opencv2.2\include\opencv2\highgui\highgui_c.h(171): error C2059: syntax error : 'constant'
1>c:\opencv2.2\include\opencv2\highgui\highgui_c.h(171): error C3805: 'constant': unexpected token, expected either '}' or a ','
1>c:\documents and settings\giga\desktop\vision\source
源代码
CVAPI(int) cvCreateTrackbar2( const char* trackbar_name, const char* window_name,
int* value, int count, CvTrackbarCallback2 on_change,
void* userdata CV_DEFAULT(0));
/* retrieve or set trackbar position */
CVAPI(int) cvGetTrackbarPos( const char* trackbar_name, const char* window_name );
CVAPI(void) cvSetTrackbarPos( const char* trackbar_name, const char* window_name, int pos );
enum
{
CV_EVENT_MOUSEMOVE =0,
CV_EVENT_LBUTTONDOWN =1,
CV_EVENT_RBUTTONDOWN =2,
CV_EVENT_MBUTTONDOWN =3,
CV_EVENT_LBUTTONUP =4,
CV_EVENT_RBUTTONUP =5,
CV_EVENT_MBUTTONUP =6,
CV_EVENT_LBUTTONDBLCLK =7,
CV_EVENT_RBUTTONDBLCLK =8,
CV_EVENT_MBUTTONDBLCLK =9
};
enum
{
CV_EVENT_FLAG_LBUTTON =1,
CV_EVENT_FLAG_RBUTTON =2,
CV_EVENT_FLAG_MBUTTON =4,
CV_EVENT_FLAG_CTRLKEY =8,
CV_EVENT_FLAG_SHIFTKEY =16,
CV_EVENT_FLAG_ALTKEY =32
};
typedef void (CV_CDECL *CvMouseCallback )(int event, int x, int y, int flags, void* param);
/* assign callback for mouse events */
CVAPI(void) cvSetMouseCallback( const char* window_name, CvMouseCallback on_mouse,
void* param CV_DEFAULT(NULL));
答案 0 :(得分:10)
我猜你的某个枚举之前曾被定义过某个地方。例如,以下代码段在VC ++ 2010中复制了该错误消息:
#define CV_GUI_NORMAL 0x00000010
enum
{
CV_GUI_EXPANDED = 0x00000000,
CV_GUI_NORMAL = 0x00000010
};
解决方案显然只定义一次CV_GUI_NORMAL。