Skip to main content
HTD
Senior II
June 14, 2022
Question

Is there a shortcut in STM32CubeIDE to quickly implement declared function / method?

  • June 14, 2022
  • 1 reply
  • 6614 views

In Visual Studio there is. I found there is the "Implement method" option in the IDE context menu, but it does nothing.

My project is properly configured, IDE knows where's the header and the source file. I can switch between them quickly. It's pretty annoying I have to type entire implementation by hand (or copy and paste it from the header) instead of some automatic function. It would be the best if all methods from the header would be automatically implemented as empty methods. Is it possible in STM32CubeIDE, or maybe I need a plugin for that?

This topic has been closed for replies.

1 reply

Markus GIRDLAND
ST Employee
June 15, 2022

Hello there,

The "Implement Method" option only works with C++ so the targeted source file needs to be .cpp in order to function.

0693W00000NrulzQAB.pngI'm not sure if perhaps there's a way to do some of the work in .c files using Templates in Window -> Preferences -> C/C++ -> Editor -> Templates.

HTD
HTDAuthor
Senior II
June 15, 2022

I tested it with a C++ file and nothing happens when I click on "Implement method":

0693W00000NruoFQAR.pngHere's where I right click:

0693W00000NruooQAB.pngThe file is saved, the source file exists and I can navigate to it by both "switch header / source" and pressing F12 (F3 with original bindings) on an already implemented method.

Markus GIRDLAND
ST Employee
June 15, 2022

Hmm, that seems odd. Did you "convert" the project or do you have a source file with .cpp?

I haven't used this method before, I just ran a simple test when I read your question earlier today. Here's how I did my test:

I set up an empty C++ project for an F4 discovery board and just added a "test.h" and "test.cpp". From the test.cpp I added a simple

#include "test.h"

This made the project structure look like this:

0693W00000Nrv4IQAR.pngI set up two test functions in the header file:

0693W00000Nrv4wQAB.pngThis allows me to use the Implement Method option:

0693W00000Nrv5LQAR.png0693W00000Nrv5aQAB.pngThis then gets added to the test.cpp:

0693W00000Nrv5uQAB.png