문제

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.

다른 팁

timespec is also the name of a struct defined in time.h

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top