Skip to content

Commit e8357c0

Browse files
committed
build: added DEBUG build guard
To prevent linkage of binary incompatible DEBUG/RELEASE binaries/runtimes
1 parent 95a438d commit e8357c0

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

modules/core/include/opencv2/core/cvdef.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,23 @@
4848
//! @addtogroup core_utils
4949
//! @{
5050

51+
#if !defined CV_DOXYGEN && !defined CV_IGNORE_DEBUG_BUILD_GUARD
52+
#if (defined(_MSC_VER) && (defined(DEBUG) || defined(_DEBUG))) || \
53+
(defined(_GLIBCXX_DEBUG) || defined(_GLIBCXX_DEBUG_PEDANTIC))
54+
// Guard to prevent using of binary incompatible binaries / runtimes
55+
// https://github.com/opencv/opencv/pull/9161
56+
#define CV__DEBUG_NS_BEGIN namespace debug_build_guard {
57+
#define CV__DEBUG_NS_END }
58+
namespace cv { namespace debug_build_guard { } using namespace debug_build_guard; }
59+
#endif
60+
#endif
61+
62+
#ifndef CV__DEBUG_NS_BEGIN
63+
#define CV__DEBUG_NS_BEGIN
64+
#define CV__DEBUG_NS_END
65+
#endif
66+
67+
5168
#ifdef __OPENCV_BUILD
5269
#include "cvconfig.h"
5370
#endif

modules/core/include/opencv2/core/mat.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ namespace cv
6262
enum { ACCESS_READ=1<<24, ACCESS_WRITE=1<<25,
6363
ACCESS_RW=3<<24, ACCESS_MASK=ACCESS_RW, ACCESS_FAST=1<<26 };
6464

65+
CV__DEBUG_NS_BEGIN
66+
6567
class CV_EXPORTS _OutputArray;
6668

6769
//////////////////////// Input/Output Array Arguments /////////////////////////////////
@@ -400,6 +402,8 @@ class CV_EXPORTS _InputOutputArray : public _OutputArray
400402

401403
};
402404

405+
CV__DEBUG_NS_END
406+
403407
typedef const _InputArray& InputArray;
404408
typedef InputArray InputArrayOfArrays;
405409
typedef const _OutputArray& OutputArray;

modules/core/include/opencv2/core/mat.inl.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@
5656

5757
namespace cv
5858
{
59+
CV__DEBUG_NS_BEGIN
60+
5961

6062
//! @cond IGNORED
6163

@@ -392,6 +394,8 @@ inline _InputOutputArray::_InputOutputArray(const ogl::Buffer& buf)
392394
inline _InputOutputArray::_InputOutputArray(const cuda::HostMem& cuda_mem)
393395
{ init(FIXED_TYPE + FIXED_SIZE + CUDA_HOST_MEM + ACCESS_RW, &cuda_mem); }
394396

397+
CV__DEBUG_NS_END
398+
395399
//////////////////////////////////////////// Mat //////////////////////////////////////////
396400

397401
inline

0 commit comments

Comments
 (0)