Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error: 'constexpr' needed for in-class initialization of static data member -- while compiling STM32ADC example #402

Closed
tfry-git opened this issue Dec 8, 2017 · 2 comments

Comments

@tfry-git
Copy link
Contributor

tfry-git commented Dec 8, 2017

When including the header file Arduino_STM32/STM32F1/libraries/STM32ADC/src/STM32ADC.h - e.g. while trying to build one of the SingeConversionInterrupt example - I get the following error:

In file included from /bla/hardware/Arduino_STM32/STM32F1/libraries/STM32ADC/examples/SingleConversionInterrupt/SingleConversionInterrupt.ino:1:0:
/bla/hardware/Arduino_STM32/STM32F1/libraries/STM32ADC/src/STM32ADC.h:155:40: error: 'constexpr' needed for in-class initialization of static data member 'const float STM32ADC::_AverageSlope' of non-integral type [-fpermissive]
     static const float _AverageSlope = 4.3; // mV/oC   //4.0 to 4.6

Also a instance of the same error for the header line immediately after that. Compiler:
arm-none-eabi-g++ (GNU Tools for ARM Embedded Processors (Arduino build)) 4.8.3 20140228 (release) [ARM/embedded-4_8-branch revision 208322]

See also http://www.stm32duino.com/viewtopic.php?f=14&t=2207 . Changing "const" to "constexpr" in this and the following line allows compilation to proceed.

@lacklustrlabs
Copy link
Contributor

lacklustrlabs commented Dec 8, 2017

Confirmed. Using -std=c++98 makes the error go away, so it was probably a side effect of the -std=gnu++11 transition.

g++ 7.2 and 6.3 reports the same error (gnu++11).

tfry-git added a commit to tfry-git/Arduino_STM32 that referenced this issue Dec 11, 2017
tfry-git added a commit to tfry-git/Arduino_STM32 that referenced this issue Dec 12, 2017
BlackBrix added a commit to BlackBrix/Arduino_STM32_PLC that referenced this issue Jan 9, 2018
lacklustrlabs pushed a commit to lacklustrlabs/Arduino_STM32 that referenced this issue Jan 21, 2018
@tfry-git
Copy link
Contributor Author

Fixed by #407.

minimum-necessary-change pushed a commit to minimum-necessary-change/Arduino_STM32 that referenced this issue Sep 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants