0

I am trying to build a DLL with C exports for the MathGeoLib library to be consumed from C#.

The code I've written so far:

#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;
}

The stdafx.h file:

#pragma once
#include "targetver.h"
#define WIN32_LEAN_AND_MEAN             // Exclude rarely-used stuff from Windows headers
// Windows Header Files
#include <windows.h>

But when I compile, I get the following error even though I defined NOMINMAX:

1>c:\build\mathgeolib\include\mathgeolib\geometry\quadtree.inl(699): error C2760: syntax error: unexpected token 'int', expected 'expression'

This is the line where Visual Studio 2017 is choking on:

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.
}

Question:

How can I fix this error ?

aybe
  • 15,516
  • 9
  • 57
  • 105

1 Answers1

2

The line #include <algorithm> is required for use of std::max .

M.M
  • 138,810
  • 21
  • 208
  • 365