This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

What is the performance difference in writing C and C++ code for ARM Cortex M7 mcu ?

Hello All,

             So far, I have been writing code for ARM Cortex M7 (STM32F7691) using C language. But I am planning to write more structured, OOPS style coding for my next application. And so, I am thinking about using C++ instead of C. Please let me know the following,

1. What will be the performance difference and also the final code size (excluding the programmer's skills )?

2. Does arm cortex m7 has good c++ compiler?

3. Specifically, Does OOPS methodology causes performance overheads?

Thank you.

Parents
  • I agree completely with the 3 above answers.

    In some cases you might be able to use assembly language as an alternative to OOP.

    Yes, this might sound strange and it's only in some cases and it's not often.

    In general, C++ is avoided on microcontrollers due to their small amount of flash memory and small amount of available RAM.

    If you have a Cortex-M7 (or a Cortex-M4 based STM32F4), then I am quite convinced that you would have plenty of both Flash memory and on-chip SRAM to use C++.

    I personally never used C++ on a microcontroller, however I'm not completely against it (I just hate overhead and wasted clock-cycles, and C++ in general is sluggish compared to C).

    -However, in many cases it's possible to write your code / objects "lightweight" (eg. almost C-like) and keep a good overview, which helps you to keep the code short or clean or quick or any combination of those.

    That might help you generate code in a short time, which would outperform a similar attempt in C; it might also help you avoid too many bugs if your code is easier to overview.

    If you're interested in C++ on Cortex-M, you might want to have a look at mbed.

    I've never tried or used mbed myself, but I think it's a great idea and certainly worth mentioning. ;)

Reply
  • I agree completely with the 3 above answers.

    In some cases you might be able to use assembly language as an alternative to OOP.

    Yes, this might sound strange and it's only in some cases and it's not often.

    In general, C++ is avoided on microcontrollers due to their small amount of flash memory and small amount of available RAM.

    If you have a Cortex-M7 (or a Cortex-M4 based STM32F4), then I am quite convinced that you would have plenty of both Flash memory and on-chip SRAM to use C++.

    I personally never used C++ on a microcontroller, however I'm not completely against it (I just hate overhead and wasted clock-cycles, and C++ in general is sluggish compared to C).

    -However, in many cases it's possible to write your code / objects "lightweight" (eg. almost C-like) and keep a good overview, which helps you to keep the code short or clean or quick or any combination of those.

    That might help you generate code in a short time, which would outperform a similar attempt in C; it might also help you avoid too many bugs if your code is easier to overview.

    If you're interested in C++ on Cortex-M, you might want to have a look at mbed.

    I've never tried or used mbed myself, but I think it's a great idea and certainly worth mentioning. ;)

Children
No data