Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

holesno

macrumors newbie
Original poster
Sep 22, 2010
1
0
I need to compile this following file using gcc in MAC OS X 10.5.8.
This code works fine in some old version of debain.
So that modifying code is not allowed.
Is it possible and how?

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/sem.h>
#include <time.h>
#include <unistd.h>

#define samplingPeriod 100000 // ns

int main(int argc,char* argv[])
{
struct itimerspec itime;
itime.it_value.tv_sec = 0;
itime.it_value.tv_nsec = samplingPeriod;

itime.it_interval.tv_sec = 0;
itime.it_interval.tv_nsec = samplingPeriod;
timer_t timer_id;
timer_create(CLOCK_REALTIME, NULL, &timer_id);
return 0;
}

/////////////////////////////////

gcc -o test test.c
test.c: In function ‘main’:
test.c:17: error: storage size of ‘itime’ isn’t known
test.c:23: error: ‘timer_t’ undeclared (first use in this function)
test.c:23: error: (Each undeclared identifier is reported only once
test.c:23: error: for each function it appears in.)
test.c:23: error: syntax error before ‘timer_id’
test.c:24: error: ‘CLOCK_REALTIME’ undeclared (first use in this function)
test.c:24: error: ‘timer_id’ undeclared (first use in this function)
 
I'm still digging around, but it appears you are using POSIX timers and OS X doesn't support them. It uses BSD timers.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.