Issue #5724 has been reported by Luis Lavena.

----------------------------------------
Bug #5724: date_core compiling issues with MinGW GCC 4.6
http://redmine.ruby-lang.org/issues/5724

Author: Luis Lavena
Status: Open
Priority: Normal
Assignee: tadayoshi funaba
Category: ext
Target version: 
ruby -v: -


Hello,

I'm having problems building date_core.c with GCC 4.6 from mingw-w64 project:

<pre>
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
</pre>

The issue seems to be associated with this piece of code:

=begin
#if !defined(HAVE_GMTIME_R)
static struct tm*
localtime_r(const time_t *t, struct tm *tm)
{
    auto struct tm *tmp = localtime(t);
    if (tmp)
	*tm = *tmp;
    return tmp;
}
#endif
=end

The following piece of code shows the same issue:

=begin
#include <stdio.h>
#include <time.h>

static struct tm*
localtime_r(const time_t *t, struct tm *a)
{
    auto struct tm *tmp = localtime(t);
    if (tmp)
	*a = *tmp;
    return tmp;
}

int main(void)
{
	return 0;
}
=end

Now, trying the same with clang shows more details:

<pre>
C:\Users\Luis\projects\sandbox>clang t.c -o t.exe
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;                \
                                 ^
t.c:5:1: error: expected ')'
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;                \
                                 ^
t.c:5:1: note: to match this '('
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:33: note:
      expanded from macro 'localtime_r'
#define localtime_r(_Time, _Tm) ({ struct tm *___tmp_tm;                \
                                ^
2 errors generated.
</pre>

Perhaps is missing a check for localtime_r in configure instead?



-- 
http://redmine.ruby-lang.org