about predefined header files

If you have a simple question and just want an answer.
User avatar
jeevanicherukuri
Member++
Posts: 17
Joined: Fri Dec 26, 2014 4:41 pm

about predefined header files

Post by jeevanicherukuri »

When i write program using xmos predefined header files, it's showing syntax error that header files are not defined. Where can i found definitions of that header files?

Are these files also not predefined in xmos library? Usually in 'c' , there is no need to again define predefined files? But what about xTime composer studio?

eg: #include<stdio.h>

srinie
XCore Addict
Posts: 158
Joined: Thu Mar 20, 2014 8:04 am

Post by srinie »

Hi,

Can you share the error message trace? Are you trying using command line or xTIMEcomposer (it should not matter whichever you use)?

Wrt using "stdio.h" - there is a light weight version of this functinality available using "print.h". You can try with this.

------------------------------------

#include <xs1.h>

#inlcude <print.h>

 

int main()

{

  printstrln("Test");

  return 0;

}
 

------------------------------------

 

srinie
XCore Addict
Posts: 158
Joined: Thu Mar 20, 2014 8:04 am

Post by srinie »

xSOFTip explorer tab has How-To examples on xC programming topics.

 

If you are looking for a ready-to-run example, try below:

#include<platform.h>
#include<stdio.h>
#include<xs1.h>

[[combinable]]
void task(int id)
{
  timer tmr;
  int count = 0;
  unsigned time;
  tmr :> time;

  while (1) {
    select
    {
      case tmr when timerafter(time) :> int now:
        printf("Counter tick at time %x on task %d\n", now, id);
        count++;
        if (count > 2)
          return;
        time += 1000;
        break;
    }
  }
}

int main () {
  //while(1){
    [[combine]]
    par {
      task(1);
      task(2);
      task(3);
    }
  //}
  return 0;
}