Use stm32CubeMX and c++

Sysprogs forums Forums VisualGDB Use stm32CubeMX and c++

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #7466
    dave93cab
    Participant

    I followed the tutorial to create an stm32f411re project using stm32CubeMX. I have a couple of issues.

    I get a lot of undefined type uint32_t messages in the Intellisense (set to CLang), but the software compiles and downloads.

    I also cannot create classes. I want the whole project to be treated as C++, but setting that option in the compiler flags does not work and causes a lot of errors.

    Any help? I wanted to use VS instead of Keil as I feel more at home in it.

    Dave

    #7467
    dave93cab
    Participant

    Disabled resharper and that solved the uint32_t issue.

    Renaming main.c to main.cpp solved the adding a class issue. Regenerating with stm32cubeMX creates a brand new main.c file though instead of merging with the existing one..

    #7468
    dave93cab
    Participant

    Sorry for being spammy, I can’t seem to edit my posts. I updated the makefile manually like so:

    $(BINARYDIR)/main.o : Src/main.c $(all_make_files) |$(BINARYDIR)
    $(CC) $(CFLAGS) -x c++ -c $< -o $@ -MD -MF $(@:.o=.dep)

    If someone has a better solution let me know. I know I should be declaring my classes outside of main.c, am a bit of a noob just messing around. Cheers

    #7469
    jeremyvnc
    Participant

    Try this:  In STMCubeMX, go to Project Settings -> Code Generator tab.  Check the “Generate peripheral initialization as a pair of ‘.c/.h’ files per IP and check “Keep User Code when re-generating”  This “should” prevent cubeMX from generating anything important in main.c, then you can just delete main.c when you re-generate your project in CubeMX or have main.c just an empty file so CubeMX will see it and skip over generating it.

    Hope this helps.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.