Browse Source

Fix min/max macro issue (#1346)

* Fix min/max macro issue

* Make NOMINMAX public, since benchmark is build under CMake, it will no longer be bothered by min/max
tags/20191113
Natsu nihui 6 years ago
parent
commit
f11b772dd1
2 changed files with 18 additions and 2 deletions
  1. +6
    -2
      src/CMakeLists.txt
  2. +12
    -0
      src/opencv.h

+ 6
- 2
src/CMakeLists.txt View File

@@ -300,11 +300,15 @@ if(NCNN_VULKAN)
target_link_libraries(ncnn PUBLIC Vulkan::Vulkan)
endif()

if(WIN32)
target_compile_definitions(ncnn
PUBLIC NOMINMAX)
endif()

if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC"
OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND CMAKE_CXX_SIMULATE_ID MATCHES "MSVC"))
target_compile_definitions(ncnn
PRIVATE _SCL_SECURE_NO_WARNINGS _CRT_SECURE_NO_DEPRECATE
PUBLIC NOMINMAX)
PRIVATE _SCL_SECURE_NO_WARNINGS _CRT_SECURE_NO_DEPRECATE)
else()
target_compile_options(ncnn
PRIVATE -Wall -Wextra -Wno-unused-function)


+ 12
- 0
src/opencv.h View File

@@ -23,6 +23,13 @@
#include <string>
#include "mat.h"

#if defined(_MSC_VER) || defined(__GNUC__)
#pragma push_macro("min")
#pragma push_macro("max")
#undef min
#undef max
#endif

// minimal opencv style data structure implementation
namespace cv
{
@@ -261,6 +268,11 @@ void resize(const Mat& src, Mat& dst, const Size& size, float sw = 0.f, float sh

} // namespace cv

#if defined(_MSC_VER) || defined(__GNUC__)
#pragma pop_macro("min")
#pragma pop_macro("max")
#endif

#endif // NCNN_OPENCV

#endif // NCNN_OPENCV_H

Loading…
Cancel
Save