Project

General

Profile

Actions

Bug #5724

closed

date_core compiling issues with MinGW GCC 4.6

Added by luislavena (Luis Lavena) over 12 years ago. Updated over 12 years ago.

Status:
Rejected
Target version:
-
ruby -v:
-
Backport:
[ruby-core:41529]

Description

Hello,

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

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

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:

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.

Perhaps is missing a check for localtime_r in configure instead?

Updated by luislavena (Luis Lavena) over 12 years ago

  • Status changed from Open to Rejected

This was caused by a bug of mingw-w64's GCC 4.6 and not Ruby.

Actions

Also available in: Atom PDF

Like0
Like0