Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Set C++ Standart to C++17
Set C++ Standart to C++17 [message #1786783] Fri, 11 May 2018 11:13 Go to next message
Julius Caesar is currently offline Julius CaesarFriend
Messages: 7
Registered: March 2018
Junior Member
Hey guys,
I'm having trouble switching for c++14 to c++17 with my G++

as you might know c++17 introduced inline static variables

http://www.nuonsoft.com/blog/2017/08/28/c17-inline-variables/

class CTest
{
private:
inline static uint32_t test;
}


gives me a compilation error
Quote:
error: 'test' declared as an 'inline' field


my console output looks like this
Quote:
Invoking: MCU G++ Compiler
xxx\Debug
arm-none-eabi-g++ -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 '-D__weak=__attribute__((weak))' '-D__packed=__attribute__((__packed__))' -DUSE_HAL_DRIVER -DSTM32F429xx -I"xxx/Inc" -I"xxx/Inc/User" -I"xxx/Inc/User/SD/XML" -I"xxx/Inc/User/display" -I"xxxx/User/SD" -I"xxx/Drivers/STM32F4xx_HAL_Driver/Inc" -I"xxx/Drivers/STM32F4xx_HAL_Driver/Inc/Legacy" -I"xxx/Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F" -I"xxx/Middlewares/ST/STM32_USB_Device_Library/Core/Inc" -I"xxx/Middlewares/ST/STemWin/Config" -I"xxx/Middlewares/ST/STemWin/inc" -I"xxx/Middlewares/ST/STM32_USB_Device_Library/Class/CustomHID/Inc" -I"xxx/Drivers/CMSIS/Device/ST/STM32F4xx/Include" -I"xxx/Middlewares/Third_Party/FatFs/src" -I"xxx/Middlewares/Third_Party/FreeRTOS/Source/include" -I"xxx/Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS" -I"xxx/Drivers/CMSIS/Include" -O2 -g3 -pedantic -Wall -Wextra -Wconversion -fmessage-length=0 -std=c++17 -ffunction-sections -c -fno-rtti -MMD -MP -MF"Src/User/wrapper.d" -MT"Src/User/wrapper.o" -o "Src/User/wrapper.o" "../Src/User/wrapper.cpp"
In file included from ../Src/User/wrapper.cpp:9:0:
xxx/Inc/User/CTransmissionBuffers.hpp:67:27: error: 'test' declared as an 'inline' field
inline static uint32_t test;


so from that i'd say that c++17 should be applied however
#if __cplusplus < 201703L
#error "C++ 17 required"
#endif


gives me an error because __cplusplus = 201402L
so i'm confused am i using the c++17 standard or not?

Could you give me a hint?
Re: Set C++ Standart to C++17 [message #1786799 is a reply to message #1786783] Sat, 12 May 2018 00:35 Go to previous messageGo to next message
David VavraFriend
Messages: 803
Registered: October 2012
Senior Member
depends on your gcc version.
I have gcc 6.3.1
Setting -std=c++17 gets __cplusplus = 201500L

According to this for GCC 6.3.0
https://gcc.gnu.org/onlinedocs/gcc-6.3.0/cpp/Standard-Predefined-Macros.html#Standard-Predefined-Macros
Quote:
...
__cplusplus ...
201103L for the 2011 C++ standard,
201402L for the 2014 C++ standard, or
an unspecified value strictly larger than 201402L for the experimental languages enabled by -std=c++1z
...


so my guess is you can only get c++14

UPDATE:
Here's the implementation schedule
https://gcc.gnu.org/projects/cxx-status.html

[Updated on: Sat, 12 May 2018 00:50]

Report message to a moderator

Re: Set C++ Standart to C++17 [message #1786808 is a reply to message #1786799] Sat, 12 May 2018 17:53 Go to previous message
Julius Caesar is currently offline Julius CaesarFriend
Messages: 7
Registered: March 2018
Junior Member
thx the last link was relay helpful :)
according to that inline variables are only supported with gcc7. I'm still stuck at gcc 6 :O
i was afraid that an old gcc version was the reason for my problems.
Thank you for your help :)
Previous Topic:Problems creating C/C++ Project
Next Topic:GDB Hardware Debugging problem
Goto Forum:
  


Current Time: Thu Nov 15 19:48:43 GMT 2018

Powered by FUDForum. Page generated in 0.02099 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top