bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: timespec_get: Fix compilation error with MSVC 14


From: Bruno Haible
Subject: Re: timespec_get: Fix compilation error with MSVC 14
Date: Mon, 05 Sep 2022 00:00:59 +0200

Paul Eggert wrote:
> > this platform's <time.h> contains a 'static inline'
> > definition of timespec_get
> 
> That violates the C standard, as it means an extern inline function 
> cannot call timespec_get.

Oh, indeed.

> Shouldn't we instead fix Gnulib's timespec_get module to work around 
> this MSVC 14 bug? That way, all we need to do is have timespec_get 
> callers depend on the timespec_get module, which they should do already.

The implementation of timespec_get for native Windows would be something
like

int
timespec_get (struct timespec *ts, int base)
{
  /* Documentation:
     
https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/timespec-get-timespec32-get-timespec64-get1
 */
#ifdef _USE_32BIT_TIME_T
  return _timespec32_get ((struct _timespec32 *) ts, base);
#else
  return _timespec64_get ((struct _timespec64 *) ts, base);
#endif
}

But I am lazy here, as 'timespec_get' is usually not the kind of function
that people will call from an extern inline function.

Bruno






reply via email to

[Prev in Thread] Current Thread [Next in Thread]