Compilation error: ‘constexpr’ needed for in-class initialization of static data member

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Compilation error: ‘constexpr’ needed for in-class initialization of static data member

igitur
Hi,

When I try to compile the current head on master branch on Linux with gcc 6.3.1 20161221, I get this error:

../../ql/cashflows/lineartsrpricer.hpp:66:47: error: ‘constexpr’ needed for in-class initialization of static data member ‘const Real QuantLib::LinearTsrPricer::defaultUpperBound’ of non-integral type [-fpermissive]
                           defaultUpperBound = 2.0000;

The same for the lower bound.

I suspect it's some kind of C++11 issue. Should I change my compiler or change something the 'const' to 'constexpr' in the .hpp file?

thanks,
Francois Botha

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev
Reply | Threaded
Open this post in threaded view
|

Re: Compilation error: ‘constexpr’ needed for in-class initialization of static data member

Luigi Ballabio
It's fixed in https://github.com/lballabio/QuantLib/pull/196. I'll merge it tomorrow, but you can pull it into your master already if you need it now.

Luigi


On Wed, Feb 8, 2017 at 8:04 PM Francois Botha <[hidden email]> wrote:
Hi,

When I try to compile the current head on master branch on Linux with gcc 6.3.1 20161221, I get this error:

../../ql/cashflows/lineartsrpricer.hpp:66:47: error: ‘constexpr’ needed for in-class initialization of static data member ‘const Real QuantLib::LinearTsrPricer::defaultUpperBound’ of non-integral type [-fpermissive]
                           defaultUpperBound = 2.0000;

The same for the lower bound.

I suspect it's some kind of C++11 issue. Should I change my compiler or change something the 'const' to 'constexpr' in the .hpp file?

thanks,
Francois Botha
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev