Open Ginkgo-Biloba opened 2 months ago
@vpisarev @opencv-alalek @mshabunin what do you think?
Quick grep has shown that we have following picture: Macro | opencv (3rdparty) | opencv_contrib |
---|---|---|
_DEBUG |
47 (8) | 2 |
NDEBUG |
288 (103) | 2 |
_DEBUG
is MSVC thing and is explicitly defined for GCC/Clang in our CMake scripts.
NDEBUG
is added to CMAKE_..._FLAGS_RELEASE
(_RELWITHDEBINFO
, _MINSIZEREL
) by CMake
So, I agree, we can switch to using NDEBUG
in all our code, or even invent our own CV_DEBUG/CV_NDEBUG
macro for better control.
Vote for CV_DEBUG
. By the way, we have also DEBUG
(without prefix _
) macro in some code.
We discussed this question a bit more and decided that it would be better to switch to NDEBUG
and not introduce new macros.
--- to make it's precondition same as
CV_DbgCheckXX
. Or further, replace all#if defined _DEBUG
with#if !defined NDEBUG
.The C++ standard only mentions
NDEBUG
as the condition ofassert
macro, no_DEBUG
.https://github.com/opencv/opencv/blob/e1fec1562714eb41ae48f97310b254618a26d248/modules/core/include/opencv2/core/base.hpp#L389-L394
https://github.com/opencv/opencv/blob/e1fec1562714eb41ae48f97310b254618a26d248/modules/core/include/opencv2/core/check.hpp#L153-L169