This simple C code compiles without errors in both MS Visual Studio/Windows 11 and GCC/Linux.
#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <time.h>
int main() {
struct tm ed_bday = {
.tm_year = 56,
.tm_mon = 7,
.tm_mday = 10,
.tm_hour = 0,
.tm_min = 0,
.tm_sec = 0,
.tm_isdst = 0,
};
time_t ed_time_epoch;
ed_time_epoch = mktime(&ed_bday);
printf("Ed was born %s\n", ctime(&ed_time_epoch));
return 0;
}
However the output differs. On MSVS it outputs:
Ed was born (null)
On GCC it outputs:
Ed was born Fri Aug 10 01:00:00 1956
I know MS prefers localtime_s(), but according to their own documentation there is the option of staying with localtime() so long as you add #define _CRT_SECURE_NO_WARNINGS 1. This does not seem to be the case