问题描述:在MFC添加类的时候出现
C1189 #error: Macro clash with min and max -- define NOMINMAX when compiling your program on Windows MatAndHObject f:\libtorch-win-shared-with-deps-debug-1.8.1+cpu\libtorch\include\c10\util\c++17.h
搞了许久,在网上一顿查找,最终解决方法是:
在创建类的头文件中, 在引入头文件之前增加3行:
#define NOMINMAX
#undef min
#undef max
如下所示:
#pragma once
#define NOMINMAX
#undef min
#undef max
#include<memory>
#include "torch/torch.h"
#include"opencv2/opencv.hpp"
#include "utils.h"
原因分析 :
个人观点:使用的libtorch中min和max函数与windows中的min和max函数有冲突