I have the following Code
#ifdef ENV_TI
typedef struct timespecT
{
Uint32 tv_sec;
Uint32 tv_nsec;
}timespec;
#endif
#ifndef ENV_TI
struct timespec currentTime; // This Line
#else
timespec currentTime;
#endif
How is the currentTime
accessible if i have NOT defined ENV_TI
flag and the timespec is defined under the ENV_TI
flag?
I am running this code on Linux, gcc compiler.
struct timespec
is a type name used in e.g. Linux, see the manual page for clock_gettime()
. You get the type declaration by doing #include <time.h>
on systems that support it. According to the manual page, this is POSIX standard functionality.
I think the code you're looking at is using the #ifdef
to declare the type for environments that don't support it natively.