[gdal-dev] Hard coded Pi constants
Mike Toews
mwtoews at gmail.com
Thu Mar 3 12:11:28 PST 2016
This is not just a MSVC issue. M_PI and other constants are not part
of the ISO standard, so if you try:
$ gcc --std=c99 small_program_with_M_PI.c
you will get "error: ‘M_PI’ undeclared"
I'm not sure if you can compile GDAL with `--std=c99`, but I don't see
any compelling reason to remove #ifndef blocks for these.
On 4 March 2016 at 06:55, Tanuj Kumar <kmrtnjscnc at gmail.com> wrote:
> This is with regard to the bug listed on
> https://trac.osgeo.org/gdal/ticket/6388
>
> The fix is to remove the hard coded pi constants, but apparently, using M_PI
> from math.h as it is breaks compilation on Visual Studio
> http://stackoverflow.com/questions/26065359/m-pi-flagged-as-undeclared-identifier
> (I haven't checked it yet myself; that would need me to switch to windows,
> and I'm on linux right now)
>
> However, we could also declare #define _USE_MATH_CONSTANTS, and then use
> M_PI without declaring it(And not just M_PI, all the other math constants
> listed on https://msdn.microsoft.com/en-us/library/4hwaceh6.aspx).
>
> Could someone please check whether math constants work in later versions of
> visual studio(Both with and without #define _USE_MATH_CONSTANTS)?
>
> Thank you
> Tanuj
More information about the gdal-dev
mailing list