I also know that someone I worked with actually found some instructions online and managed to get the compiler to compile C++ code.
I do know that the Microchip C32 compiler is open sourced, and you can download the source. Is there any future plans or ongoing development on this? For more detail, see the Technical Report on C++ Performance In some cases, the C++ came out slower and larger, some cases slower and smaller, or faster and larger, and even faster and smaller! So, the answer to your question is that it depends heavily on the compiler, but in general, it need make no difference at all. Bjarne Stroustrup did a comparison of a bunch of C/C++ compilers to compare time and space performance for a number of operations. hex file and running time of the program increase when we use C++ instead of C?Īs I said, there may be no difference. See my answer on why C++ is suitable on embedded CPUs. Even very experienced coders seem to have no idea how the language works. Sadly, there is so much misunderstanding surrounding C++. Indeed, there are PCs based on the MIPS (or at least, there used to be). It can deal with pointers and a stack as well as a PC. They have up to 64kB RAM, and are based on the MIPS core, which is a properly grown up 32-bit processor. It's perfectly possible to write C++ (with objects and everything) that produces the exact asm output you would have got if you'd used C. As long as the compiler understands the limitations of the target device, and the user understands the language too, there's really no problem. Knowing that it's possible to write C for an MCU, the same answers apply to the question of writing C++ on an MCU.
Some C compilers simply won't let you write re-entrant (recursive) code which absolutely requires a stack. The compiler will also be extra careful with memory allocation, it won't try to create a heap and may not create a stack. and B) the compiler has been written especially for the MCU.
It's possible because A) the software developers know that they have to be a little bit careful: don't use malloc() etc. A high level language, on 256 byte RAM MCU ? Impossible. The exact same questions were (and still are) asked about C on an MCU.
When people ask about using C++ on an MCU, I find it constructive to compare C++ to C. B) many MCUs don't handle pointers well, so use of variables on the stack really kills performance. Why do they struggle with a heap/stack? For two reasons: A) many MCUs have limited RAM, not enough for a heap certainly, and barely enough for a stack. Long answer, C++ certainly encourages the use of a heap and / or stack, which smaller MCUs with limited RAM will struggle with. Short answer, no, there are no hardware limitations. Is there any hardware limitations that prevents us to use C++? Comeau's is only $50, but it will probably take some effort to get the whole toolchain and libraries working properly. Take a look at LLVM or Comeau's C++ compiler which both do that. Using a pre-build step, convert the C++ to C, then give the (nasty looking) C to your normal C compiler. For dsPIC, there is the IAR Systems C++ Compiler (although it's very old and not supported).Īnother option is to use a C++ to C converter. Is it ever gonna be possible to use C++ for coding PICs?