While I am debugging my small porting program, I have a question about the differences between types.
Here is my source (below):
1 #include <time.h>
2 #include <stdio.h>
3
7 int main () {
8 clock_t now;
9 struct tm * mac_time;
10 char *time_str;
11 now = time (NULL);
12 mac_time = localtime((const long *)&now);
13
13 time_str = asctime(mac_time);
14 printf("Now : %s\n",time_str);
15 return 0;
16 }
Firstly, it works correctly, there is no error right now. But I have a question about the differences in casting types.
On line 12, since there was a warning about type discrimination, I changed the value type for debugging.
but what is the difference between
12 mac_time = localtime((const long *)&now);
and
12 mac_time = localtime(&(const long *)now);
I thought that there is no difference between each other, because it differs only from "casted value address" and "value address casted".
But the compiler issues a warning to the latter.
Will you give me some tips on this issue?
source
share