MCUXpresso-Convert project from C to C++

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MCUXpresso-Convert project from C to C++

5,067 Views
mayursavaj
Contributor III

Hi,

I want to convert my existing MCUXpresso C projects into C++.

mcuxpresso 10.3‌

Please help me with some example.

Thanks in advance,

Mayur Savaj

5 Replies

4,708 Views
BlackNight
NXP Employee
NXP Employee

Hi,

there are ways to change the 'nature' (this is what the language support is called in Eclipse lingo) of a project, but this is really an expert thing, and you have to know what you are doing.

What I recommend is that you create a new C++ project from the Wizard and add your stuff to it.

I hope this helps,

Erich

4,707 Views
kucheravy
Contributor I

   Totally agree, that's an expert thing and I, personally, having the same question and would like to learn how to do that. The main goal in my case is to take an example project as a base one and then extend it with custom code but I really would like to use C++ language features and the example project is a C project. I don't plan to restructure the original project, I just want to add new abilities to it. The example I'm talking about is definitely not a simple one, it is a zigbee based example. So, if I have to create a separate C++ project I at least need instructions how to add a zigbee stack to the newly create project.

0 Kudos
Reply

4,707 Views
ErichStyger
Specialist I
0 Kudos
Reply

4,707 Views
kucheravy
Contributor I

   Interesting but unfortunately following these instructions is not possible. Somewhere in the middle, at the topic of "C++ startup code" it says "Locate the C startup code in the project: The easiest approach is to rename it to a C++ file with .cpp extension: " and then it suggest to make certain changes to that file. In my case with KW41Z the C generated example project has startup_MKW41Z4.S startup file. It is written in assembler. Impossible to make the suggested changes and that is one of the important things.

   Meanwhile I run into other issues with C++ projects. I was experimenting a lot.

1. If I simply create a C++ project and then try to use InstallIRQHandler from fsl_common which is basically added to the project by default and I even cannot untick it, it fails with linker errors like those:

   undefined reference to `__RAM_VECTOR_TABLE_SIZE_BYTES'

I learned that those symbols (like __RAM_VECTOR_TABLE_SIZE_BYTES) are supposed to be declared in the linker script file but by default C++ sets automatic linker script managing and as a result the symbols are missing and there is no example how to add what is necessary for the automatically added source code to the linker script. Apparently a custom linker script is generated with C projects and everything compiles in that case.

2. It looks like I run into another situation with the wrong order of linking obj files. I have a bunch of "undefined reference to" for the symbols which definitely exist in other obj files. I checked the methods signatures. Everything looks fine so I tend to believe the problem is the wrong linking order and I don't know how to resolve that. I hope this issue might automatically resolve if I resolve point 1 but I don't know how to do that.

   All that is besides I still don't know how to port C to C++ and trying other approaches such as generating a basic C++ and then copy everything from C. That is much more tedious and does not work yet anyway.

0 Kudos
Reply

4,707 Views
ErichStyger
Specialist I

Let me see if I can come up with an example for MCUXpresso IDE, similar to what I did in Processor Expert, gcc C++ and Kinetis-L with MQXLite | MCU on Eclipse 

Erich

0 Kudos
Reply