While I debug my minor porting program, I have question about type casting differences.
Here is my source (below) :
1 #include <time.h>
2 #include <stdio.h>
3
7 int main () {
8 clock_t now; //unsigned long
9 struct tm * mac_time; // const long
10 char *time_str;
11 now = time (NULL);
12 mac_time = localtime((const long *)&now);
13 // localtime ( const long <- unsigned long)
13 time_str = asctime(mac_time);
14 printf("Now : %s\n",time_str);
15 return 0;
16 }
First, it works properly, there's no error right now. But I have a question about type casting difference.
In line 12, since type casting warning has occurred, I changed the value's type for debug.
but what is the difference between
12 mac_time = localtime((const long *)&now);
and
12 mac_time = localtime(&(const long *)now);
I thought there's no difference to each other, because this is only different from 'casted value's address and 'value's address casted'.
But complier throws out warning message latter one.
Will you give me some advice for this type casting issue?