elmot / clion-embedded-arm

OpenOCD + STM32CubeMX support for CLion
https://blog.jetbrains.com/clion/2017/12/clion-for-embedded-development-part-ii
Other
170 stars 29 forks source link

Document how to change to a C++ Project #118

Closed johnthagen closed 6 years ago

johnthagen commented 6 years ago

Fixes #117


This change is Reviewable

johnthagen commented 6 years ago

@elmot

main.c with main() function is auto-generated, and will be rewritten every now and then. The bare bone project should be still based in C, and C++ parts should be called C code

Good point, I was planning to rename back to main.c if I needed to regenerate from STM32CubeMX, but we shouldn't prescribe that for the common case. I've removed the comment

better to add CXX as 3rd or 2nd language rather than add the comment

Done. For pure-C projects, this won't hurt anything either.

it's not enough to mention C++ here, the compiler should be set up as well.

What do you mean by this? It looks like the template is setting up the correct c++ compiler. It's been working for me. Anything else need to be done?

elmot commented 6 years ago

There should be SET(CMAKE_CXX_COMPILER_WORKS 1) clause. At least it did not work for me without that. You may be having multi-target gcc installed, and that's why your g++ works nicely without this line.

PS. Can you, please, reply in reviewable (that purple button at the very top). I use it on daily basis and it seems to be really handy review instrument.

johnthagen commented 6 years ago

@elmot I know that exception handling should normally be avoided on embedded tasks, but for completeness I was trying to test if try/catch would work and the CPU seems to be halting on throw. I wanted to be sure our solution here enables as much of C++ as people may want. Any ideas on:

A) If exception unwinding is possible on bare-metal STM32F3/F4, etc. B) If there are some flags we should document for those wanting to use exception handling within pure C++ code?

johnthagen commented 6 years ago

@elmot Sure I'll open a different issue for exception handling.