Skip to main content
Ahmet Yasin CİVAN
Associate III
January 24, 2022
Question

Why is not std::vector or std::unique_ptr using at stm32 projects with cpp?

  • January 24, 2022
  • 6 replies
  • 4295 views

Why is not std::vector or std::unique_ptr using at stm32 projects with cpp? When I examine stm32 projects that use cpp , I do not see modern cpp features.

    This topic has been closed for replies.

    6 replies

    KnarfB
    Super User
    January 24, 2022

    If you generate a project with STM32CubeMX/STM32CubeIDE, all the library code (CMSIS, HAL) is the same plain C, even if you choose C++. Your own C++ code can do whatever it want (and what is supported in the runtime library).

    There are C++ 3rd party abstractions for peripherals like STM32duio or home grown, but not vendor supported. And, concerning all the "HAL is bloatware" discussions in this forum, C++ would have a hard time becoming a first class citicen here.

    hth

    KnarfB

    Ahmet Yasin CİVAN
    Associate III
    January 24, 2022

    Thank you for answer.

    TDK
    January 24, 2022

    Dynamic memory allocation, which is used by both objects you referenced, is often frowned upon in embedded projects with limited flash and RAM memory.

    I use C++ almost exclusively for my own code in projects. It has many useful features that contribute no additional memory/complexity resources.

    "If you feel a post has answered your question, please click ""Accept as Solution""."
    Ahmet Yasin CİVAN
    Associate III
    January 25, 2022

    Understood thanks.

    KnarfB
    Super User
    January 24, 2022

    BTW: There is ETL for embedded: https://www.etlcpp.com/

    Ahmet Yasin CİVAN
    Associate III
    January 25, 2022

    Thank you, etl is very usefull.