bug-gnulib
[Top][All Lists]
Advanced

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

Re: New warnings on emacs-26 branch with gcc 8.2.0


From: Bruno Haible
Subject: Re: New warnings on emacs-26 branch with gcc 8.2.0
Date: Sat, 18 Aug 2018 18:09:27 +0200
User-agent: KMail/5.1.3 (Linux/4.4.0-130-generic; KDE/5.18.0; x86_64; ; )

> > There is also one function cast warning from gnulib code:
> > C:/emacs/git/emacs/master/lib/gettimeofday.c: In function 'initialize':
> > C:/emacs/git/emacs/master/lib/gettimeofday.c:48:9: warning: cast between 
> > incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 
> > 'void (*)(FILETIME *)' {aka 'void (*)(struct _FILETIME *)'} 
> > [-Wcast-function-type]
> >           (GetSystemTimePreciseAsFileTimeFuncType) GetProcAddress 
> > (kernel32, "GetSystemTimePreciseAsFileTime");
> >           ^

The cast is there, because the results of GetProcAddress or dlsym
need to be cast to the proper function type before they can be
invoked. This code uses GetProcAddress so that it can exploit
features of newer Windows versions while at the same time still
work on older Windows versions.

The warning is there because you specified -Wcast-function-type.
You *wanted* to get informed about the cast. You got informed.

So, there are 4 options:
  1) Use static reference to Windows API functions.
  2) Use '#pragma GCC diagnostic ignored "-Wcast-function-type"'
  3) Remove -Wcast-function-type from the compiler options.
  4) Live with the warning.

I'm opposed to 1), since it removes either features or portability.

I could do 2), but it does not feel like the right thing, to silence
a compiler warning when the user has explicitly requested a warning.

So, please choose among 3) and 4).

Bruno




reply via email to

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