octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ‘pi’ shadows a global declaration


From: John W. Eaton
Subject: Re: ‘pi’ shadows a global declaration
Date: Mon, 10 Jul 2017 09:19:19 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0

On 07/09/2017 11:30 PM, Dmitri A. Sergatskov wrote:
Probably no a big problem. Mostly fyi:

../src/liboctave/numeric/lo-specfun.cc:3460:19: warning: declaration of
‘pi’ shadows a global declaration [-Wshadow] const float pi =
3.14159265358979323846f; ^~
../src/liboctave/numeric/lo-specfun.cc:3198:25: note: shadowed
declaration is here static const double pi = 3.14159265358979323846; ^~

Yeah, I noticed that. We currently use a mixture of these kinds of locally defined constants and macros like M_PI that may be defined by math.h. Since we generally want to avoid macros from C-language headers in C++ code we try to only use C++ headers instead of C headers (<cmath> instead of <math.h>) but we also define _GNU_SOURCE, which currently causes macros like M_PI to be defined, at least on some systems.

So we could just use the macros, but I'm not sure that we should depend on them as they are not standard for C++ code. Maybe we should define our own header file for math constants and use them consistently?

Whatever we do, I'd prefer to use the same constants in all Octave code.

jwe




reply via email to

[Prev in Thread] Current Thread [Next in Thread]