time.h
및 sys/time.h
헤더에 여러 선언을 사용하는 라이브러리를 시도하고 있습니다. 무엇을해도 나는 cpp 파일에서 헤더를 사용할 수 없습니다. 정의는 전혀 정의하지 않은 것처럼 보입니다.헤더 포함 작동하지 않습니다
#ifndef IW_STD_TIME_H
#define IW_STD_TIME_H
#include <sys/types.h>
#ifndef _TIME_T_DEFINED
#define _TIME_T_DEFINED
typedef long time_t;
#endif
#define CLOCKS_PER_SEC 1000
#ifndef _CLOCK_T_DEFINED
typedef long clock_t;
#define _CLOCK_T_DEFINED
#endif
#ifndef _TM_DEFINED
struct tm
{
int tm_sec; /* seconds after the minute - [0,59] */
int tm_min; /* minutes after the hour - [0,59] */
int tm_hour; /* hours since midnight - [0,23] */
int tm_mday; /* day of the month - [1,31] */
int tm_mon; /* months since January - [0,11] */
int tm_year; /* years since 1900 */
int tm_wday; /* days since Sunday - [0,6] */
int tm_yday; /* days since January 1 - [0,365] */
int tm_isdst; /* daylight savings time flag */
};
#define _TM_DEFINED
#endif
struct timespec
{
time_t tv_sec; /* Seconds. */
long int tv_nsec; /* Nanoseconds. */
};
S3E_BEGIN_C_DECL
#ifdef __ARMCC_VERSION
#define localtime localtime_rvct
#define localtime_r localtime_rvct_r
#endif
time_t time(time_t *t);
void tzset(void);
char *asctime(const struct tm *tm);
char *asctime_r(const struct tm *tm, char *buf);
char *ctime(const time_t *timep);
char *ctime_r(const time_t *timep, char *buf);
struct tm *gmtime(const time_t *timep);
struct tm *gmtime_r(const time_t *timep, struct tm *result);
struct tm *localtime(const time_t *timep);
struct tm *localtime_r(const time_t *timep, struct tm *result);
time_t mktime(struct tm *tm);
size_t strftime(char *s, size_t max, const char *format, const struct tm *tm);
clock_t clock(void);
double difftime(time_t time1, time_t time0);
int nanosleep(const struct timespec *req, struct timespec *rem);
#if defined __GNUC__ && !defined __APPLE__ && !defined I3D_ARCH_MIPS
extern char *_tzname[2];
extern int _daylight;
extern long int _timezone;
#define tzname _tzname
#define daylight _daylight
#define timezone _timezone
#else
extern char *tzname[2];
extern int daylight;
extern long int timezone;
#endif
#define CLOCK_REALTIME 1
#define CLOCK_MONOTONIC 2
typedef int clockid_t;
int clock_getres(clockid_t clk_id, struct timespec *res);
int clock_gettime(clockid_t clk_id, struct timespec *tp);
int clock_settime(clockid_t clk_id, const struct timespec *tp);
S3E_END_C_DECL
#include <sys/time.h>
#endif /* !IW_STD_TIME_H */
이가 SYS/time.h가 정의하는 방법입니다 - -이 time.h의 모습입니다
#ifndef IW_STD_SYS_TIME_H
#define IW_STD_SYS_TIME_H
#include "s3eTypes.h"
#include <time.h>
#ifndef _WINSOCK2API_
S3E_BEGIN_C_DECL
#ifndef _TIME_T_DEFINED
#define _TIME_T_DEFINED
typedef long time_t;
#endif
typedef long suseconds_t;
struct timeval
{
time_t tv_sec; /* seconds */
suseconds_t tv_usec; /* microseconds */
};
struct timezone
{
int tz_minuteswest; /* minutes west of Greenwich */
int tz_dsttime; /* type of DST correction */
};
int gettimeofday(struct timeval *tv, struct timezone *tz);
int settimeofday(const struct timeval *tv , const struct timezone *tz);
int utimes(const char *filename, const struct timeval times[2]);
S3E_END_C_DECL
#endif // XBOX
#endif // !IW_STD_SYS_TIME_H
나는 #include<time.h>
및하지로 CPP 파일에 포함 typedef long time_t;
조차 작동합니다. 그러나 선언을 cpp 파일 자체에 넣으면 작동합니다. 나는 여기서 바보 같은 것을 놓치고 있다고 확신한다. 어떤 생각?
PS :이 파일에 언급 된 매크로를 정의하는 방법입니다 -
#define S3E_BEGIN_C_DECL extern "C" {
#define S3E_END_C_DECL }
업데이트 :
오류가이처럼 -
오류 3 오류 C2079 : 'TV'사용 정의되지 않은 구조체 'timeval' 오류 4 오류 C3861 : 'gettimeofday': 식별자를 찾을 수 없습니다.
마치 hea의 모든 정의가 der는 전혀 정의되지 않았습니다. 그리고 이러한 헤더가있는 곳 어디에서나 이런 일이 일어나고 있습니다.
정확히 무엇이 작동하지 않습니까? 제발 제발하시기 바랍니다. –
@ πάνταῥε definition 정의가 작동하지 않습니다. 정의되지 않거나 구문 오류와 같은 오류가 발생합니다. 여기에 몇 가지 오류의 예입니다 - '오류 오류 C2079 : '식별자가 나는 내가 할 수있는 말은 found' 없습니다 :'gettimeofday를 ':'TV는 '정의되지 않은 구조체'timeval 형 ' 오류 오류 C3861을 사용 헤더를 포함하더라도 정의를 사용하지 마십시오. – noob
'# include'd가''입니까 아니면''입니까? 둘 다 포함하지 않았다면 그렇게하십시오. –
Wintermute