Menu

#43 2.4.4 fails to compile with Visual Studio 2017

v1.0_(example)
open
nobody
None
1
2019-12-20
2019-12-20
No

When compiling utils\mgltask.cpp with Visual Studio 2017 I get the following error:

C:\...\mathgl-2.4.4\utils\mgltask.cpp(138): error C2065: 'M_LN10': undeclared identifier [C:\...\mathgl-2.4.4\build32\utils\mgltask.vcxproj]

The Math Constants page in the Microsoft documentation suggests the following incantation is required (for using <math.h>):

#define _USE_MATH_DEFINES
#include <math.h>

And this works :o). I've hacked this into my local copy for now as I'm not sure how you want to handle this MS-ism properly in your code. The following would be enough unless you want to tie it down to a specific version of the MS compiler:

#include <iostream>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#ifdef _MSC_VER
#define _USE_MATH_DEFINES
#endif
#include <math.h>
#include <time.h>

Discussion

Anonymous
Anonymous

Add attachments
Cancel





MongoDB Logo MongoDB