Update:
This small example can also reproduce these compiler errors:
#include <iostream>
#include <libnova/utiltiy.h>
int main() { return 0; }
#include <iostream>
#include <libnova/utiltiy.h>
int main() { return 0; }
To copy to clipboard, switch view to plain text mode
Errors occure, because <iostream> also includes <pthread.h> somewhere down the road. And <pthread.h> has this funny stuff in it:
#undef gmtime_r
#define gmtime_r(_Time,_Tm) ({ struct tm *___tmp_tm; \
pthread_testcancel(); \
___tmp_tm = gmtime((_Time)); \
if (___tmp_tm) { \
*(_Tm) = *___tmp_tm; \
___tmp_tm = (_Tm); \
} \
___tmp_tm; })
#undef gmtime_r
#define gmtime_r(_Time,_Tm) ({ struct tm *___tmp_tm; \
pthread_testcancel(); \
___tmp_tm = gmtime((_Time)); \
if (___tmp_tm) { \
*(_Tm) = *___tmp_tm; \
___tmp_tm = (_Tm); \
} \
___tmp_tm; })
To copy to clipboard, switch view to plain text mode
Then comes <libnova/utility.h> and declares:
struct tm *gmtime_r (time_t *t, struct tm *gmt);
struct tm *gmtime_r (time_t *t, struct tm *gmt);
To copy to clipboard, switch view to plain text mode
When I include <libnova/utility.h> first, it will compile sucessfully. But being forced to include headers in a specific order feels very wrong. At least in this case. And it may not be possible in a very big project.
Is this a bug in the C library provided with MinGW?
What's the best way to handle this? For the time being, I could surround the conflicting declaratioin in <libnova/utility.h> with #ifndef...#endif.
Any advice?
Bookmarks