Compiling Program has trouble, need help!

Hello everyone,

I have a simple code for testing QNX 6.2.1 which was installed in my system recently.

Here is source code:

[i]#include <process.h>
#include <unistd.h>
#include <time.h>
#include <sys/syspage.h>
main()
{
double dt,dt_max,dt_min;
double tic,i,j;
uint64_t t1,t2,t3,cps;
pid_t pid1;
useconds_t usec;
timespec rqtp;
int nret,schedule;
sched_param sp;

cps = SYSPAGE_ENTRY(qtime)->cycles_per_sec;
tic = 1.0/cps; // about 1.2 ns

pid1 = getpid();
printf( "I'm process %d\n", pid1 );

setprio(pid1,63);
sched_getparam(pid1,&sp);
sp.sched_priority = 63;
sched_setscheduler(pid1,SCHED_FIFO,&sp); // FIFO reduces jitter

schedule = sched_getscheduler(pid1);
t3 = ClockCycles();
dt_max = 0.0;
dt_min = 1.0e6;
for(i=0;i<1000;i++) {
	t1 = ClockCycles();
// we can have 8300 loops (~420us) before jitter gets big
	// for round robin scheduling
	// for FIFO scheduling it is about 11000 (550us)
	// probably has something to do with time slices
	// or starvation protection mechanism
for(j=0;j<10000;j++) ClockCycles();

	// argument is an unsigned integer value in seconds
	// nanosleep is more useful
                            // sleep(1);
	// arugment is an unsigned integer in micro seconds
	// 2000 us seems to be the minimum
	// not so accurate compared to nanosleep
                            // usleep(4000);
t2 = ClockCycles();
dt = (double)(t2-t1	)*tic / 1.0e-6; // in usec
	// 2000us seems to be about the default minimum
// probably depends on the set resolution of the timer
	// zero nsec results in around 1000 us delay
nsec2timespec( &rqtp, 0 );
nret = nanosleep(&rqtp,NULL);
	
if(dt > dt_max) dt_max = dt;
if(dt < dt_min) dt_min = dt;		

}

printf("\ndt_max = %lf , dt_min = %lf",dt_max,dt_min);

printf("\nschedule = %d, %d",schedule,(int)SCHED_FIFO);


printf("\ndone.\n");

}[/i]

When I compile it, there are some errors. My file test1.c locates in folder /usr.

# gcc -I/usr/include test1.c
test1.c: In function main': test1.c:9: uint64_t’ undeclared (first use in this function)
test1.c:9: (Each undeclared identifier is reported only once
test1.c:9: for each function it appears in.)
test1.c:9: parse error before t1' test1.c:12: timespec’ undeclared (first use in this function)
test1.c:12: parse error before rqtp' test1.c:14: sched_param’ undeclared (first use in this function)
test1.c:14: parse error before sp' test1.c:16: cps’ undeclared (first use in this function)
test1.c:24: sp' undeclared (first use in this function) test1.c:26: SCHED_FIFO’ undeclared (first use in this function)
test1.c:29: t3' undeclared (first use in this function) test1.c:33: t1’ undeclared (first use in this function)
test1.c:48: t2' undeclared (first use in this function) test1.c:53: rqtp’ undeclared (first use in this function)

what’s wrong here?

Any answer is welcome.

You need to include more header files.

eg: stdint.h declares your “uint64_t”. so you need to add
#include <stdint.h>.

Check those files in /usr/include…