You are here

Porting C++ files | Cypress Semiconductor

Porting C++ files

Summary: 2 Replies, Latest post by gbmhunter on 28 Apr 2013 10:11 PM PDT
Verified Answers: 0
Last post
Log in to post new comments.
user_228878049's picture
152 posts


When I heard about PSoC 4 and the board being compatible with Arduino shields, I was wondering how I can port al the C++ files of arduino library to be ported to PSoC Creator. Can I write any code in C++. Is it possible?

If at all if I were to compile C++ files in PSoC Creator, how do I change the physical layer of that library.


user_119377051's picture
866 posts

Hi, This article introduce the way to use c++ in PSoC,
Might help for you.

Anyway, Even in this way has some problems, because PSoC is using user module's code wrote by C. Someone want to use c++ who have to add wrapping software for the user modules. Do you do that?

user_151909305's picture
36 posts

I write PSoC code with C++, and have written a small tutorial about how to do it here...

Getting PSoC Creator to compile C++ is the first step, you will still have to do things like convert non-standard data types and port any code the accesses hardware peripherals, system features (the PSoC and ATmega are different).

If you want to go to C, then Google porting Arduino code to C, there are many resources on this, and it doesn't matter if they were not doing it to go to a PSoC, most of it will be same, thanks to the portability to C (and C++) code. However, if you do this, you will loose all the nice stuff you could do with the Arduino, like for example,

LiquidCrystal lcd(12, 13, ..)


You can of course create structures in C which emulate the classes in C++, but you will have to pass in the structure to the member functions, and associating functions with the structures (to emulate member functions in C++), will mean having to use function pointers and consequentially functions pointers to call them. In other words, not nice, and I reckon it's better to try the C++ way first, and then fall back to C if you have to.

Log in to post new comments.