Classes

New to XMOS and XCore? Get started here.
Post Reply
JohnRobert
Active Member
Posts: 34
Joined: Fri Nov 02, 2012 8:10 am

Classes

Post by JohnRobert »

G'day,

Another silly question on my part... But how do you define classes in XC?

For example...

Code: Select all

class Profiler {
    int start, end;
    timer tmr;
  public:
    void startTimer (){tmr :> start;}
    void stopTimer (){tmr :> end;}
    int getTimeMS () {return ((end-start)/10000);}
};
Note, I coded half of this in browser, so I'm not 100% sure that the syntax is right.

When I put this into the IDE, it comes up with the "Syntax Error" error on "class Profiler", "public:" and "};"... Any clues to what's wrong with the syntax?

Also, where might I find out more about the syntax of XC? I looked in the programming guide for XC, but no avail.

John


User avatar
Bianco
XCore Expert
Posts: 754
Joined: Thu Dec 10, 2009 6:56 pm
Contact:

Post by Bianco »

XC does not support object oriented programming.
You can use C++ though, but you can't use the nice XC syntax for resources like channels, ports and timers in that case of course, but instead have to use libs.

The XC programming guide contains basically everything there is.
JohnRobert
Active Member
Posts: 34
Joined: Fri Nov 02, 2012 8:10 am

Post by JohnRobert »

Thanks, interesting, but I will be able to work around that :)
Post Reply