c++ - 获取 C2760 语法错误:意外标记“int”,std::max 的预期“表达式”(...)
问题描述
我正在尝试使用 C 导出构建一个 DLL,以便从 C# 中使用MathGeoLib库。
到目前为止我写的代码:
#include "stdafx.h"
#include "MathGeoLib/MathGeoLib.h"
OBB* OptimalEnclosingOBB(const vec* pointArray, int numPoints)
{
const auto obb1 = OBB::OptimalEnclosingOBB(pointArray, numPoints);
const auto obb2 = new OBB(obb1);
return obb2;
}
stdafx.h 文件:
#pragma once
#include "targetver.h"
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
// Windows Header Files
#include <windows.h>
但是当我编译时,即使我定义了以下错误NOMINMAX
:
1>c:\build\mathgeolib\include\mathgeolib\geometry\quadtree.inl(699): error C2760: syntax error: unexpected token 'int', expected 'expression'
这是 Visual Studio 2017 令人窒息的地方:
https://github.com/juj/MathGeoLib/blob/master/src/Geometry/QuadTree.inl#L699
template<typename T>
int QuadTree<T>::NumNodes() const
{
return std::max<int>(0, nodes.size() - 3); // The nodes rootNodeIndex+1, rootNodeIndex+2 and rootNodeIndex+3 are dummy unused, since the root node is not a quadrant.
}
问题:
我该如何解决这个错误?
解决方案
该行#include <algorithm>
是使用 所必需的std::max
。
推荐阅读
- powershell - Powershell Invoke-Command -ErrorVariable 输出不完整
- mysql - 当我尝试在 phpmyadmin 中创建触发器时,不断收到错误 #1064
- c++ - 使用 Poco::NotificationCenter 在通知处理程序中发送通知时出现死锁
- javascript - 构建插件/库时的构造函数问题
- javascript - 当没有错误时,为什么我的错误样式会应用于元素?
- vue.js - Vue无法读取未定义的属性'$refs'
- r - 回归循环中表的新对象
- python - 如何从 Tensorflow 中的冻结模型(pb 文件)中找到 output_node_names?
- c# - 解析 json 时出现许多空条目
- vb.net - win32 api 查找特定进程访问的文件