PSoC Creator C++?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hi all, I'm wondering what the current state of C++ support is in the latest versions of PSoC Creator?  I see some traffic about limited support, but that was quite some time ago.  Has anything improved?

Thanks!
Chris
 

26 Replies
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Bob can comment on this but GNU, GCC is  open source so its support

   

model is one of open source community.

   

 

   

    

   

          https://gcc.gnu.org/onlinedocs/gcc-4.8.4/gcc/Standards.html#Standards

   

 

   

Regards, Dana.

0 Likes
Anonymous
Not applicable

As far as I can see, PSOC Creator 3.1 does not support C++, for example there is no choice for creating a c++ (.cpp) file in the "project/new item" menu and no editor support for C++ keywords highlighting. The underlying compiler such as GCC (depends on your configuration) can support C++ from decades (it supported C++ before supporting ARMv7-M).

   

 

   

Furthermore, C++ is tricky to use when your platform has less than 256K of flash and less than 64K of RAM.

   

 

   

Regards,

   

PNN

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

The demand for C++ is increasing and Cypress knows that, the customers voted for C++.

   

So there is no question whether but when we will get C++. Since the current status is that all PSoC projects are written in C we have to consider how the switching to C++ is performed, how co-existence of the different language can be maintained and the re-writing of the component libraries and documentation will cost a lot of $$ and time.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

Thanks folks.  So it sounds like one is still on their own for C++ though it is probably possible.

   

To Bob's point, I think that is good news that it will probably be coming.  I think Cypress can look to some of the other tool / chip vendors and ecosystems for how to add support, how to handle having both, etc. I'm not sure it would have to be a total major rewrite, though...I don't see why most of the existing libraries and documentation can't stay the same?  Since C++ is "just" a superset of C, backwards compatible, etc.  Similar to having assembler libraries called from C functions, as things are today.

   

Shooting from the hip here, I could be wrong.  Thoughts?

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

I saw this online -

   

 

       

    

   

          

   

http://www.mbedded.ninja/programming/microcontrollers/psoc/using-cplusplus-with-psoc-creator

   

http://www.cypress.com/?app=forum&id=2492&rID=79797

           

 

   

 

   

Regards, Dana.

0 Likes
Anonymous
Not applicable

One year later, and still no C++ support.  I've been using PSoC since when CY8C26 came out.  I've migrated from 100% assembly to using C on the 3/5LP devices and now I am very much wanting/"needing" C++ support as well and hope it comes soon.  I may have to look at switching to a different IDE and program/debug interface on my next design.  Not sure which I would switch to though.  I have spent too much time banging my head on the keyboard with Eclipse, but it might be worth it for C++ support.

0 Likes
Anonymous
Not applicable

According the the response from a support case, this is barely on their radar and will not be included in their next major version of Creator.  I suggest that if anyone wants C++, they post to this thread to let them know how many of us are interested.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

I would like to see C++ in Creator. Full stop.

   

On the other hand, we are talking about embedded systems, no operating system, no (or few) peripherals and limited number of internal components. So what will be the advantages we get from C++? Housekeeping might consume some of the valuable resources as flash and sram. A PSoC is not a Raspberry.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

The definition of "embedded" gets a bit blurry.  My current project includes an RTOS, TCP/IP stack, control of a serially connected display unit with full-color touchscreen, 3 SPI, 1 UART, 1 CAN, and 2 OneWire interfaces, voltage and signal frequency measurement, data and event logging, and, of course, about a dozen simple digital IOs.

   

The term "embedded" is becoming less and less meaningful as it can be an 8-bit controller with 256 bytes of RAM and 2k of Flash or it can be a 5LP with 64k RAM and 256k flash.  I wouldn't want to use very much C++ at all on the former, but my current project could have been made much easier to handle with a few C++ features.

0 Likes
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted
0 Likes
Anonymous
Not applicable

+1 for CPP also. The mbedded.ninja is interesting. 

0 Likes
Anonymous
Not applicable

Really Cypress? You guys do such awesome stuff with your PSOC series, and you have a pretty solid marketing campaign (CypressPSOC is pretty active on reddit), but you don't support something as fundamental as C++? If you were running your own compiler then sure, I would mildly understand as C++ is huge, but you are using ARM's fork of GCC! So the toolchain already supports C++, it's just that you have to allow the option of generating C++ files in the IDE and throwing the right flags at GCC (which currently has to be done manually) and fixing all the issues present in the other post in this thread.

   

Since you seem to have your own parser for auto complete and syntax highlighting, you could argue that C++ support for those will be too much work (though you will have to do it eventually, times are changing). How about instead you have an "Experimental" option in the IDE which allows generation of C++ files, all while lacking syntax highlighting? Then those of us who want to can fiddle with using Clion/Atom/vim/notepad for syntax highlighting and proper auto complete, as a glorified text editor.

   

And, c++ is most certainly usable for embedded. Sure, you shouldn't use the c++ implementation of strings, or exceptions, but on the other hand you get to use classes along with RAII, constexpr for compile time behavior while maintaining type safety (instead of preprocessor macors), namespaces, operator overloading, templates, the standard library (well, a decent chunk of it), and many other benefits. Not to mention, almost every vendor out there that makes MCU's or IDE's targeted towards MCU's supports C++ in one way or other (Keil, IAR, Atollic, Atmel, Freescale, NXP, even Microchip). Heck, even companies which create their own architectures like Adapteva with their 16 core Epiphany MCU, XMOS with their 4+ core MCU's, and Parallax with their 8 core propeller all support C++.

   

Some resources for those who found this post when googling "Cypress C++" like I did and are considering C++ for embedded, feel free to PM me for links to various resources since mollom thinks I am spamming. Instead, here is a single video show casing C++11 for small embedded devices. Don't forget, Arduino which uses an Atmega328P can handle c++ even.

   

https://www.youtube.com/watch?v=J-tA17slViE

NiBu_1198441
Level 2
Level 2
5 replies posted 5 questions asked First question asked

I will add my vote for C++. I've told the sales reps that C++ support is a requirement for my company to use PSoC parts in production products. We have successfully used C++ on STM32 projects with 256 KB of FLASH and a few KB of RAM. You can use C++ in embedded systems as long as you fully understand how the code you write will be compiled. 

   

We've tried to compile a test project for PSoC using standard GNU ARM tools, but that has fallen flat on it's face for numerous reasons. 

   

Hopefully this will happen sooner than later.

0 Likes
Anonymous
Not applicable

Yes I also vote for C++. Please Cypress....

0 Likes
Anonymous
Not applicable

Dear Cypress,

   

Here's another vote for C++.  It makes many things (e.g. importing code from the rest of the world!) much easier.

   

Isn't Cypress the least bit embarrassed that the lowly Arduino supports C++?  You guys and your products are generally pretty great, but really!

0 Likes
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Dear Sirs at Cypress,

Yes, I vote for C++, too.

I've written dozens of sensor drivers and sample programs in C++.

Although I have already ported a few of them into PSoC Creator, it was not a fun work.

Reinventing the wheel is a waste, but parting with one is, being the politest, misfortune.

moto

0 Likes

According to this survey is C more often used as C++. So you should have started with C for your drivers 😉

Bob

0 Likes
Anonymous
Not applicable

The survey you mention Bob covers all the programming languages, where the embedded world only uses a subset of them (C#, VB, SQL don't have much sense here).

Thanks to this survey you can select what type of device you're interested in.

By selecting "Embedded" only, C++ arrives second, right behind C.

Arduino arrives third, and one could argue that Arduino is C++ as well.

Cpp_2.PNG

Now if we select the "Languages popular on open source hubs", C++ arrives first.

Cpp_1.png

Furthermore, PSoC Creator 4.1 is already shipped with C AND C++ compilers and it can compile C++ source files with a bit of tweaking as already demonstrated here.

What is stopping Cypress from implementing C++ support in the PSoC Creator IDE ?

Furthermore, PSoC Creator 4.1 is already shipped with C AND C++ compilers and it can compile C++ source files with a bit of tweaking as already demonstrated here.

Would vote for C++ support in PSoc Creator as well because it is not only about enhanced features, but also a habit of thinking and programming. Even basic encapsulation in C++ is also very helpful.


@rofoc_1675286 Thank you very much for the link on tweaking for PSoc Creator 4.1.

I have had a look into the linked page. I suppose maybe the reason why Cypress has not supported C++ is as stated in this paragraph from the above link:

The standard C++ library contains many powerful utilities, however, most of these come at the expense of using plenty of code/RAM space, as well as potentially using exceptions (I have not got exceptions to work correctly on a PSoC device).

For example, including <iostream> can cause your memory to instantly overflow. I assume this is probably because of advanced features such a locale support. Upon removing the include, the memory usage didn’t shrink back to normal until I did a clean build.

Because of this, I almost use no standard C++ library features for embedded firmware. Instead, I have written a number of firmware modules which emulate the most useful standard C++ library features (such as strings, vectors, e.t.c) but are suitable for running on microcontrollers. You can download the modules from the MToolkit repository on GitHub.

It has suggested a solution: emulating those memory-eating features of C++.

If you have libraries or codes programmed in C++ to migrate onto PSoc, maybe you can compile C++ into C using some tools as mentioned here.

0 Likes
Anonymous
Not applicable

C++ for the lads. surely.

0 Likes
NiBu_1198441
Level 2
Level 2
5 replies posted 5 questions asked First question asked

I agree, I've asked the FAE's over the years for C++ support. It doesn't appear to be anywhere close to Cypress's radar. For those that argue these parts are too small to support C++, you are wrong. I've deployed 30+ commercial products over the years that all use C++. They are all embedded super loop systems. The smallest system had 256 KB of flash and 32 KB of RAM. Many systems have more resources, but it is all in how you write your code. If you stay away from exception handling, RTII, and massive layers of polymorphism, we have found our C++ code to be more compact and faster than straight C (BIG caveat emptor ***if you are careful with how you write your code***). We did get a simple Hello World C++ program running with a PSoC 5 a few years ago. You have to export your design and use makefiles. Then you have to do a lot of linker magic. I believe we ran into some issue with the configuration of the part and abandoned C++ for C on the PSoC.

0 Likes
KaPa_2418181
Level 2
Level 2

We too would much like to see native C++ support in PSoC Creator. Of course on embedded devices you do not use things like exceptions, dynamic memory allocation, or dynamic casts, but C++ has lots of other features that are very useful and efficient for use in embedded projects. Most other device manufacturers support C++ in their IDEs, even for some 8-bit devices with low memory. C++ is in itself not any more memory-hungry or inefficient than C when used correctly, while at the same time offering many useful features.

Please Cypress, support C++ in your IDEs.

0 Likes
romi_644456
Level 1
Level 1

The thing is, it's not complicated (or at least shouldn't be). One can say all they want about how one should have written code, or whether C++ is "appropriate" for an embedded application or not. None of that matters. The simple fact is that there EXISTS a lot of code out there already in C++ already on embedded platforms. For example, a ton of Arduino code. It is ridiculous that Cypress will not enable the ability to reuse this code base just because they are too lazy to enable EXISTING C++ compilers on their platform. I mean, the compiler tool chain naturally supports C++, so it's like they have to go out of their way to not allow it.

I, for example, have a bunch of Arduino code I would LIKE very much to migrate to the PSoC platform. But Cypress seems to be resistant to the idea of making it EASY for people to migrate TO THEIR PLATFORM from other platforms, like Arduino. This makes no sense. They do a great job of making it easy to use their platform from scratch but make it impossible to migrate existing code from other platforms that happen to utilize C++. I can easily drop in modules and all sorts of things...except for existing C++ code. For that I either have to rewrite the code or do a major amount of hacking of the platform to get it to work.

And how does it make sense that lower power processors (most Arduinos) seem to be able to utilize C++ by default, but I can't migrate to a more powerful platform because it for some reason lacks C++ that lesser platforms have? So it's like I have to choose between a better processor platform but with lesser language tools and reuse, or a lesser processor platform with better language tools and reuse.

0 Likes
WaMa_286156
Level 5
Level 5
First comment on blog 100 replies posted 50 replies posted

Look at this article from 2013:

https://blog.mbedded.ninja/programming/microcontrollers/psoc/using-cplusplus-with-psoc-creator/

The only thing missing when doing it that way is the try { }catch() which could be important.

0 Likes

I have followed the mentioned steps in the mbedded.ninja link of tweaking PSoc Creator for compiling C++ programs. It works.

Now my only problem is that the syntax highlighting does not recognise the keyword "class" although the compilation and building can all be successfully done.

Anyone has any solution to solve this problem?

0 Likes
ThBa_282891
Level 3
Level 3
First like received First like given

We use the eclipse plugin with a lot of nasty workarounds for C++. It works and makes perfectly sense, also on this small controller but the usability is a nightmare.

If Creator would support C++ naively and would get rid of the logical file structure, it would be definitely the best embedded IDE in existence for me.

0 Likes