Error Message


#1

on the line with “struct tm”, I keep getting this error message “Redefinition of ‘tm’”

I can’t figure out how to fix it. Any ideas?


#2

Please post your code (between the Code tags.)


#3

The error is on line 4. If i change it from “tm” to a different name, it appears to compile fine, but I don’t get why.

[code]#include <time.h>
#include <stdio.h>

struct tm {
int tm_sec; // Seconds after the minute [0-60]
int tm_min; // minutes after the hour [0-59]
int tm_hour; // hours since midnifght [0-59]
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 Saving Time Flag
long tm_gmtoff; // offset from CUT in seconds
char *tm_zone; // timezone abbreviation
};

int main(int argc, const char * argv[])
{

long secondsSince1970 = time(NULL);
printf("it has been %ld seconds since 1970\n", secondsSince1970);

struct tm now;
localtime_r(&secondsSince1970, &now);
printf("the time is %d : %d : %d\n", now.tm_hour, now.tm_min, now.tm_sec);

return 0;

}[/code]

EDIT
also, I just changed it to a tpyedef, and that worked too – no error.