Enabled CV_Assert and such to print the function name with Visual C++.
Also, I made a separate macro for the current function name, which helps simplify a lot of code that uses it.
This commit is contained in:
@@ -164,7 +164,7 @@ public:
|
||||
|
||||
int code; ///< error code @see CVStatus
|
||||
string err; ///< error description
|
||||
string func; ///< function name. Available only when the compiler supports __func__ macro
|
||||
string func; ///< function name. Available only when the compiler supports getting it
|
||||
string file; ///< source file name where the error has occured
|
||||
int line; ///< line number in the source file where the error has occured
|
||||
};
|
||||
@@ -209,16 +209,19 @@ typedef int (CV_CDECL *ErrorCallback)( int status, const char* func_name,
|
||||
CV_EXPORTS ErrorCallback redirectError( ErrorCallback errCallback,
|
||||
void* userdata=0, void** prevUserdata=0);
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define CV_Error( code, msg ) cv::error( cv::Exception(code, msg, __func__, __FILE__, __LINE__) )
|
||||
#define CV_Error_( code, args ) cv::error( cv::Exception(code, cv::format args, __func__, __FILE__, __LINE__) )
|
||||
#define CV_Assert( expr ) if(!!(expr)) ; else cv::error( cv::Exception(CV_StsAssert, #expr, __func__, __FILE__, __LINE__) )
|
||||
|
||||
#if defined __GNUC__
|
||||
#define CV_Func __func__
|
||||
#elif defined _MSC_VER
|
||||
#define CV_Func __FUNCTION__
|
||||
#else
|
||||
#define CV_Error( code, msg ) cv::error( cv::Exception(code, msg, "", __FILE__, __LINE__) )
|
||||
#define CV_Error_( code, args ) cv::error( cv::Exception(code, cv::format args, "", __FILE__, __LINE__) )
|
||||
#define CV_Assert( expr ) if(!!(expr)) ; else cv::error( cv::Exception(CV_StsAssert, #expr, "", __FILE__, __LINE__) )
|
||||
#define CV_Func ""
|
||||
#endif
|
||||
|
||||
#define CV_Error( code, msg ) cv::error( cv::Exception(code, msg, CV_Func, __FILE__, __LINE__) )
|
||||
#define CV_Error_( code, args ) cv::error( cv::Exception(code, cv::format args, CV_Func, __FILE__, __LINE__) )
|
||||
#define CV_Assert( expr ) if(!!(expr)) ; else cv::error( cv::Exception(CV_StsAssert, #expr, CV_Func, __FILE__, __LINE__) )
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define CV_DbgAssert(expr) CV_Assert(expr)
|
||||
#else
|
||||
|
@@ -774,11 +774,7 @@ namespace cv { namespace ogl {
|
||||
CV_EXPORTS bool checkError(const char* file, const int line, const char* func = "");
|
||||
}}
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#define CV_CheckGlError() CV_DbgAssert( (cv::ogl::checkError(__FILE__, __LINE__, __func__)) )
|
||||
#else
|
||||
#define CV_CheckGlError() CV_DbgAssert( (cv::ogl::checkError(__FILE__, __LINE__)) )
|
||||
#endif
|
||||
#define CV_CheckGlError() CV_DbgAssert( (cv::ogl::checkError(__FILE__, __LINE__, CV_Func)) )
|
||||
|
||||
#endif //__cplusplus
|
||||
|
||||
|
Reference in New Issue
Block a user