Hello guys,
Today while making Ruby codebase compile against GCC 4.6.3 from
Ruben's builds found an issue:
make[2]: Entering directory
`/c/Users/Luis/projects/oss/oneclick/rubyinstaller/sandbox/ruby19_build/ext/date'
generating date_core-i386-mingw32.def
compiling ../../../../../../ruby/ext/date/date_core.c
../../../../../../ruby/ext/date/date_core.c:3572:1: error: expected
identifier or '(' before '{' token
make[2]: *** [date_core.o] Error 1
make[2]: Leaving directory
`/c/Users/Luis/projects/oss/oneclick/rubyinstaller/sandbox/ruby19_build/ext/date'
make[1]: *** [ext/date/all] Error 2
GCC is not very helpful on the error message, but thanks to clang:
t.c:5:1: error: expected identifier or '('
localtime_r(const time_t *t, struct tm *tm)
^
C:/Users/Luis/Tools/DevKit/4.6.3-w32/mingw/bin/../lib/clang/3.1/../../../i686-w64-mingw32/include\pthread.h:411:34:
note:
expanded from macro 'localtime_r'
#define localtime_r(_Time, _Tm) ({ struct tm *___tmp_tm; \
The full bug report is here:
http://redmine.ruby-lang.org/issues/5724
Ruby source code is checking for gmtime_r being a function and since
gmtime_r is not present, localtime_r is defined.
Now, beyond the Ruby issue, what is funny is this is defined in
pthread.h, which was not included by me.
This can be simply reproduced:
#include <time.h>
static struct tm*
localtime_r(const time_t *t, struct tm *tm)
{
auto struct tm *tmp = localtime(t);
if (tmp)
*tm = *tmp;
return tmp;
}
int main(void)
{
return 0;
}
C:\Users\Luis\Projects\sandbox>gcc t.c -o t.exe
t.c:4:1: error: expected identifier or '(' before '{' token
I've never explicitly required pthread.h, but seems time.h is doing that for me.
Now, looking at time.h, seems that localtime_r is only defined if
_POSIX is defined, but is never defined.
Questions:
1) Should I assume that time.h dependency is a requirement or is a bug?
2) Even when using win32 native threading model my application will
depend on winpthread?
3) Why even _POSIX is not defined localtime_r is?
Please excuse my naive questions and thanks in advance for your time.
--
Luis Lavena
AREA 17
-
Perfection in design is achieved not when there is nothing more to add,
but rather when there is nothing more to take away.
Antoine de Saint-Exupéry
------------------------------------------------------------------------------
Cloud Services Checklist: Pricing and Packaging Optimization
This white paper is intended to serve as a reference, checklist and point of
discussion for anyone considering optimizing the pricing and packaging model
of a cloud services business. Read Now!
http://www.accelacomm.com/jaw/sfnl/114/51491232/
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public