[PATCH] Fix M_PI with -std=c++11 on Mingw

Dirk Hohndel dirk at hohndel.org
Tue Nov 3 07:20:52 PST 2015


On Tue, Nov 03, 2015 at 01:47:28PM +0200, Lubomir I. Ivanov wrote:
> From: "Lubomir I. Ivanov" <neolit123 at gmail.com>
> 
> The introduction of -std=c++11 breaks usage of M_PI in Mingw,
> but technically M_PI is not standard C or C++.
> 
> Defining M_PI in units.h solves the issue.

This is one of those things that just boggle my mind.
I tested on three different platforms and it all worked fine. But then
more or less all of my "daily builds" broke with exactly this error.
Clearly my "usual set" of platforms I test on are especially lenient...

> the Mingw math.h header does have the _USE_MATH_DEFINES
> macro check and it's one of the ways to get M_PI defined.
> 
> so, i've tried doing it the proper way:
> -- #define _USE_MATH_DEFINES
> -- #include <math.h>
> 
> ..in all locations where we have <math.h> and M_PI, but it doesn't
> work! something, somehwhere is undefining _USE_MATH_DEFINES
> and i don't have a good solution.

That's weird. But in the end I don't think I care. Defining our own PI
isn't the end of the world.

Thanks for the patch, Lubomir

/D


More information about the subsurface mailing list