Skip to content

Conflicting definition of gettimeofday() #32

@larskanis

Description

@larskanis

Ruby declares gettimeofday() on Windows, but the function is also declared in mingw-w64's sys/time.h. Both definitions are incompatible and extension builds fail, if both ruby.h and sys/time.h are included. This is the related error message from rake gem:native of the grpc gem:

compiling ../../../../src/ruby/ext/grpc/rb_byte_buffer.c
In file included from ../../../../src/ruby/ext/grpc/rb_grpc.h:23:0,
                 from ../../../../src/ruby/ext/grpc/rb_byte_buffer.c:27:
/usr/share/mingw-w64/include/sys/time.h:42:13: error: conflicting types for 'gettimeofday'
 int __cdecl gettimeofday(struct timeval *__restrict__,
             ^~~~~~~~~~~~
In file included from /usr/local/rake-compiler/ruby/i686-w64-mingw32/ruby-2.7.0/include/ruby-2.7.0/ruby/defines.h:371:0,
                 from /usr/local/rake-compiler/ruby/i686-w64-mingw32/ruby-2.7.0/include/ruby-2.7.0/ruby/ruby.h:29,
                 from ../../../../src/ruby/ext/grpc/rb_byte_buffer.c:19:
/usr/local/rake-compiler/ruby/i686-w64-mingw32/ruby-2.7.0/include/ruby-2.7.0/ruby/win32.h:318:12: note: previous declaration of 'gettimeofday' was here
 extern int gettimeofday(struct timeval *, struct timezone *);
            ^~~~~~~~~~~~

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions