Skip to content

Commit 7f608db

Browse files
committed
core: move compiler defines from base.hpp into cvdef.h
1 parent d61ad04 commit 7f608db

2 files changed

Lines changed: 86 additions & 86 deletions

File tree

modules/core/include/opencv2/core/base.hpp

Lines changed: 0 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -283,84 +283,6 @@ enum BorderTypes {
283283
//! @addtogroup core_utils
284284
//! @{
285285

286-
//! @cond IGNORED
287-
288-
//////////////// static assert /////////////////
289-
#define CVAUX_CONCAT_EXP(a, b) a##b
290-
#define CVAUX_CONCAT(a, b) CVAUX_CONCAT_EXP(a,b)
291-
292-
#if defined(__clang__)
293-
# ifndef __has_extension
294-
# define __has_extension __has_feature /* compatibility, for older versions of clang */
295-
# endif
296-
# if __has_extension(cxx_static_assert)
297-
# define CV_StaticAssert(condition, reason) static_assert((condition), reason " " #condition)
298-
# elif __has_extension(c_static_assert)
299-
# define CV_StaticAssert(condition, reason) _Static_assert((condition), reason " " #condition)
300-
# endif
301-
#elif defined(__GNUC__)
302-
# if (defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L)
303-
# define CV_StaticAssert(condition, reason) static_assert((condition), reason " " #condition)
304-
# endif
305-
#elif defined(_MSC_VER)
306-
# if _MSC_VER >= 1600 /* MSVC 10 */
307-
# define CV_StaticAssert(condition, reason) static_assert((condition), reason " " #condition)
308-
# endif
309-
#endif
310-
#ifndef CV_StaticAssert
311-
# if !defined(__clang__) && defined(__GNUC__) && (__GNUC__*100 + __GNUC_MINOR__ > 302)
312-
# define CV_StaticAssert(condition, reason) ({ extern int __attribute__((error("CV_StaticAssert: " reason " " #condition))) CV_StaticAssert(); ((condition) ? 0 : CV_StaticAssert()); })
313-
# else
314-
template <bool x> struct CV_StaticAssert_failed;
315-
template <> struct CV_StaticAssert_failed<true> { enum { val = 1 }; };
316-
template<int x> struct CV_StaticAssert_test {};
317-
# define CV_StaticAssert(condition, reason)\
318-
typedef cv::CV_StaticAssert_test< sizeof(cv::CV_StaticAssert_failed< static_cast<bool>(condition) >) > CVAUX_CONCAT(CV_StaticAssert_failed_at_, __LINE__)
319-
# endif
320-
#endif
321-
322-
// Suppress warning "-Wdeprecated-declarations" / C4996
323-
#if defined(_MSC_VER)
324-
#define CV_DO_PRAGMA(x) __pragma(x)
325-
#elif defined(__GNUC__)
326-
#define CV_DO_PRAGMA(x) _Pragma (#x)
327-
#else
328-
#define CV_DO_PRAGMA(x)
329-
#endif
330-
331-
#ifdef _MSC_VER
332-
#define CV_SUPPRESS_DEPRECATED_START \
333-
CV_DO_PRAGMA(warning(push)) \
334-
CV_DO_PRAGMA(warning(disable: 4996))
335-
#define CV_SUPPRESS_DEPRECATED_END CV_DO_PRAGMA(warning(pop))
336-
#elif defined (__clang__) || ((__GNUC__) && (__GNUC__*100 + __GNUC_MINOR__ > 405))
337-
#define CV_SUPPRESS_DEPRECATED_START \
338-
CV_DO_PRAGMA(GCC diagnostic push) \
339-
CV_DO_PRAGMA(GCC diagnostic ignored "-Wdeprecated-declarations")
340-
#define CV_SUPPRESS_DEPRECATED_END CV_DO_PRAGMA(GCC diagnostic pop)
341-
#else
342-
#define CV_SUPPRESS_DEPRECATED_START
343-
#define CV_SUPPRESS_DEPRECATED_END
344-
#endif
345-
346-
#define CV_UNUSED(name) (void)name
347-
348-
#if defined __GNUC__ && !defined __EXCEPTIONS
349-
#define CV_TRY
350-
#define CV_CATCH(A, B) for (A B; false; )
351-
#define CV_CATCH_ALL if (false)
352-
#define CV_THROW(A) abort()
353-
#define CV_RETHROW() abort()
354-
#else
355-
#define CV_TRY try
356-
#define CV_CATCH(A, B) catch(const A & B)
357-
#define CV_CATCH_ALL catch(...)
358-
#define CV_THROW(A) throw A
359-
#define CV_RETHROW() throw
360-
#endif
361-
362-
//! @endcond
363-
364286
/*! @brief Signals an error and raises the exception.
365287
366288
By default the function prints information about the error to stderr,
@@ -400,14 +322,6 @@ CV_INLINE CV_NORETURN void errorNoReturn(int _code, const String& _err, const ch
400322
# endif
401323
#endif
402324

403-
#if defined __GNUC__
404-
#define CV_Func __func__
405-
#elif defined _MSC_VER
406-
#define CV_Func __FUNCTION__
407-
#else
408-
#define CV_Func ""
409-
#endif
410-
411325
#ifdef CV_STATIC_ANALYSIS
412326

413327
// In practice, some macro are not processed correctly (noreturn is not detected).

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

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,92 @@ namespace cv { namespace debug_build_guard { } using namespace debug_build_guard
8282
#define __CV_VA_NUM_ARGS_HELPER(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, N, ...) N
8383
#define __CV_VA_NUM_ARGS(...) __CV_VA_NUM_ARGS_HELPER(__VA_ARGS__, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)
8484

85+
#if defined __GNUC__
86+
#define CV_Func __func__
87+
#elif defined _MSC_VER
88+
#define CV_Func __FUNCTION__
89+
#else
90+
#define CV_Func ""
91+
#endif
92+
93+
//! @cond IGNORED
94+
95+
//////////////// static assert /////////////////
96+
#define CVAUX_CONCAT_EXP(a, b) a##b
97+
#define CVAUX_CONCAT(a, b) CVAUX_CONCAT_EXP(a,b)
98+
99+
#if defined(__clang__)
100+
# ifndef __has_extension
101+
# define __has_extension __has_feature /* compatibility, for older versions of clang */
102+
# endif
103+
# if __has_extension(cxx_static_assert)
104+
# define CV_StaticAssert(condition, reason) static_assert((condition), reason " " #condition)
105+
# elif __has_extension(c_static_assert)
106+
# define CV_StaticAssert(condition, reason) _Static_assert((condition), reason " " #condition)
107+
# endif
108+
#elif defined(__GNUC__)
109+
# if (defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L)
110+
# define CV_StaticAssert(condition, reason) static_assert((condition), reason " " #condition)
111+
# endif
112+
#elif defined(_MSC_VER)
113+
# if _MSC_VER >= 1600 /* MSVC 10 */
114+
# define CV_StaticAssert(condition, reason) static_assert((condition), reason " " #condition)
115+
# endif
116+
#endif
117+
#ifndef CV_StaticAssert
118+
# if !defined(__clang__) && defined(__GNUC__) && (__GNUC__*100 + __GNUC_MINOR__ > 302)
119+
# define CV_StaticAssert(condition, reason) ({ extern int __attribute__((error("CV_StaticAssert: " reason " " #condition))) CV_StaticAssert(); ((condition) ? 0 : CV_StaticAssert()); })
120+
# else
121+
template <bool x> struct CV_StaticAssert_failed;
122+
template <> struct CV_StaticAssert_failed<true> { enum { val = 1 }; };
123+
template<int x> struct CV_StaticAssert_test {};
124+
# define CV_StaticAssert(condition, reason)\
125+
typedef cv::CV_StaticAssert_test< sizeof(cv::CV_StaticAssert_failed< static_cast<bool>(condition) >) > CVAUX_CONCAT(CV_StaticAssert_failed_at_, __LINE__)
126+
# endif
127+
#endif
128+
129+
// Suppress warning "-Wdeprecated-declarations" / C4996
130+
#if defined(_MSC_VER)
131+
#define CV_DO_PRAGMA(x) __pragma(x)
132+
#elif defined(__GNUC__)
133+
#define CV_DO_PRAGMA(x) _Pragma (#x)
134+
#else
135+
#define CV_DO_PRAGMA(x)
136+
#endif
137+
138+
#ifdef _MSC_VER
139+
#define CV_SUPPRESS_DEPRECATED_START \
140+
CV_DO_PRAGMA(warning(push)) \
141+
CV_DO_PRAGMA(warning(disable: 4996))
142+
#define CV_SUPPRESS_DEPRECATED_END CV_DO_PRAGMA(warning(pop))
143+
#elif defined (__clang__) || ((__GNUC__) && (__GNUC__*100 + __GNUC_MINOR__ > 405))
144+
#define CV_SUPPRESS_DEPRECATED_START \
145+
CV_DO_PRAGMA(GCC diagnostic push) \
146+
CV_DO_PRAGMA(GCC diagnostic ignored "-Wdeprecated-declarations")
147+
#define CV_SUPPRESS_DEPRECATED_END CV_DO_PRAGMA(GCC diagnostic pop)
148+
#else
149+
#define CV_SUPPRESS_DEPRECATED_START
150+
#define CV_SUPPRESS_DEPRECATED_END
151+
#endif
152+
153+
#define CV_UNUSED(name) (void)name
154+
155+
#if defined __GNUC__ && !defined __EXCEPTIONS
156+
#define CV_TRY
157+
#define CV_CATCH(A, B) for (A B; false; )
158+
#define CV_CATCH_ALL if (false)
159+
#define CV_THROW(A) abort()
160+
#define CV_RETHROW() abort()
161+
#else
162+
#define CV_TRY try
163+
#define CV_CATCH(A, B) catch(const A & B)
164+
#define CV_CATCH_ALL catch(...)
165+
#define CV_THROW(A) throw A
166+
#define CV_RETHROW() throw
167+
#endif
168+
169+
//! @endcond
170+
85171
// undef problematic defines sometimes defined by system headers (windows.h in particular)
86172
#undef small
87173
#undef min

0 commit comments

Comments
 (0)