2012-04-17 76 views
-3

我使用立体视觉源代码,并给出了一个错误VC++错误 - 语法错误:“常量”上枚举

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)); 

谢谢 http://pastebin.com/dpbCxLgK

+1

您能否指出源代码中的哪一行是#117,假设它来自highgui_c.h文件。 – uesp 2012-04-17 12:06:18

+0

http://pastebin.com/9FdJa0mK – user558126 2012-04-17 12:15:06

+0

在那个pasebin版本中,它是第190行的另一个错误(我试图解决它,并删除了一个;)。所以不是那个问题 – user558126 2012-04-17 12:19:27

回答

9

我猜你的枚举之一是以前定义过的。例如,下面的代码段复制在VC 2010的错误消息:

#define CV_GUI_NORMAL 0x00000010 

enum 
{ 
    CV_GUI_EXPANDED = 0x00000000, 
    CV_GUI_NORMAL  = 0x00000010 
}; 

解决方案是明显为仅一次定义CV_GUI_NORMAL。