Classes

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

Classes

Postby JohnRobert » Sat Nov 03, 2012 11:47 pm

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

Postby Bianco » Sun Nov 04, 2012 1:12 am

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

Postby JohnRobert » Sun Nov 04, 2012 4:04 am

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

Who is online

Users browsing this forum: No registered users and 2 guests