This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSPM0L2228: Example projects with GCC Compiler and Linker warnings and the behaviour of "new"

Part Number: MSPM0L2228

Tool/software:

I was starting to see some unexpected build errors in my own project, and have returned to the examples on the launchpad MSPM0L2228 to try and understand what is happening.

Two problems I can see at the moment:

  • Taking an example C++ project results in 6 warning messages.
  • Extending a C++ project to use a singleton pattern results in linker errors, that can only be resolved by linking with the library stdc++_nano.

These are explained in more detail below, can I ask if I am doing something wrong or missing a library please?

C++ project warning messages:

Taking the gpio_toggle_output_cpp project from the SDK examples and building it with GCC 12.2.1, results in the following warnings:

These do not appear to stop the build from working however, we would like to resolve these warnings, and feels like we are not linking everything that is required.

Further to this, for an example C++ project we were expecting C++ libraries to be linked, however only the following are linked in the example project:

C++ project linker errors for singleton pattern:

Using the same gpio_toggle_output_cpp project, and added the simple class:

and instantiating in main with 

MyTest tester = MyTest::GetInstance();
results in the following linker error:
Linking with stdc++, makes the problem worse:
Changing again to link with stdc++_nano resulted in a successful build, still with the original warnings from the initial project:

Further testing determined that new can be called from main or a class method that is not static with no errors and no need to link with any other libraries.

I currently do not understand what is the root cause of this, and appreciate any help.