OpenCV中奇怪的无与伦比的花括号 [英] Strange unmatched curly brace in OpenCV
问题描述
我正在使用适用于iPhone的OpenCV版本,但遇到了一个有点奇怪的错误.在使用拼接器时,某些导入的标头现在抱怨此行上不匹配的'{':
I am using the version of OpenCV for iPhone, and I have encountered a somewhat strange error. In using the stitcher, some of the imported headers are now complaining about an unmatched '{' on this line:
enum { NO, FEATHER, MULTI_BAND };
NO
是objc.h中的宏,定义为
NO
is a macro from objc.h which is defined as
#define NO __objc_no
编译器期望一个'}'与枚举的开头相匹配,尽管稍后会有一个.发生什么事了?
And the compiler is expecting a '}' to match the opening of the enum, even though there is one just a little later on. What is happening?
推荐答案
很长一段时间以来,我一直遇到相同的问题,而我现在发现了一种解决方法.如您所言,这是UIKit中NO-makro定义的问题.您需要做的是转到您的.pch文件并替换
I have been having the same problem for a long time and I have just now discovered a workaround. As you stated correctly it is a problem with definition of the NO-makro in UIKit. What you need to do is go to your .pch-file and replace
#ifdef __cplusplus
#import <opencv2/opencv.hpp>
#endif
使用
#ifdef __cplusplus
#import <opencv2/opencv.hpp>
#import <opencv2/stitching/detail/blenders.hpp>
#import <opencv2/stitching/detail/exposure_compensate.hpp>
#endif
因此,您生成的.pch应该看起来像这样:
So your resulting .pch should look something like this:
//
// Prefix header for all source files of the 'Project' target in the 'Project' project
//
#import <Availability.h>
#ifndef __IPHONE_3_0
#warning "This project uses features only available in iOS SDK 3.0 and later."
#endif
#ifdef __cplusplus
#import <opencv2/opencv.hpp>
#import <opencv2/stitching/detail/blenders.hpp>
#import <opencv2/stitching/detail/exposure_compensate.hpp>
#endif
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#endif
通过这种方式,可以在UIKit中的NO-makro之前定义blenders.hpp和Exposure_compensate.hpp中的NO枚举.
This way the NO-enums in blenders.hpp and exposure_compensate.hpp are defined before the NO-makro in UIKit.
这篇关于OpenCV中奇怪的无与伦比的花括号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!