Skip to main content
AKlep.1
Associate
October 29, 2020
Question

C++ Startup file

  • October 29, 2020
  • 2 replies
  • 1367 views

I would like the interrupt handlers to be written in the C ++ style, that is, they are static classes, but there is practically no information on the Internet about where to get a C ++ startup file or how to make it yourself. Has anyone encountered such a problem?

This topic has been closed for replies.

2 replies

TDK
Super User
October 29, 2020

> Has anyone encountered such a problem?

I'm not convinced it's a problem.

The startup file is in assembly because it needs to load the data segments into memory and other low-level things. Don't think you're going to replicate that in C++. Not sure what you mean by "static class".

Also see:

https://community.st.com/s/question/0D53W000006PEaOSAW/when-will-stm32-cmsis-device-startup-file-migrate-from-asm-to-c

"If you feel a post has answered your question, please click ""Accept as Solution""."
Nikita91
Lead II
October 30, 2020

Cortex-M architecture is designed to allow to aesily write the startup code in C. Have a look to:

http://adastra-soft.com/design-a-generic-startup-file-and-a-linker-script/

But C++ is more complicatd.

The interrupt handlers have to be C functions, or static member of a class (and where to get the class pointer?).

See: https://community.arm.com/developer/tools-software/tools/f/keil-forum/26156/c-interrupt

It is a big work to write all in C++.

It is probably more interesting to write a C to C++ wrapper for each ISR.