Hi,

first of all, please see the discussion about
compiler warnings in the documentation:

http://pod.tst.eu/http://cvs.schmorp.de/libev/ev.pod#COMPILER_WARNINGS

On Tue, Aug 29, 2023 at 05:07:23PM +0200, Christian Wendt he/him 
<c...@brainaid.de> wrote:
> libev-4.33/ev.c:2143:31: warning: ‘ev_default_loop_ptr’ initialized and
> declared ‘extern’

The warning succinctly describes this line of correct code. The question
that it doesn't answer is: why does it warn about it a line of code that
pretty much can be found verbatim in the C standard document as an example
of correct code? It looks to me to be more of a stylistic warning.

> I don't see that EV_API_DECL is necessary in ev.c.

Thats because you have perfect knowledge of the contents of that macro. If
we hardcoded the values of all macros, indeed many things would be
possible, but they are macros so they can be changed, also in ways we did
not fully predict in advance.

> Without EV_API_DECL, the warning would not be issued.

Right, but other warnings can and will be emitted by other compilers for
the changed line. You can't win, other than by writing correct code and
exercising reason.

(And in fact, if I remember correctly this was introduced specifically to
make it compile with clang).

> If this is about hiding all API in case of EV_API_STATIC, then maybe there
> should be an EV_API_HIDE declared like this:

There are a multitude of other options that complicate code and
maintenance of the library. Given that its impossible to anticipate every
compiler warning of every compiler, we opted for clear and simple code in
this case, rather than hacks to avoid a spurious compiler warning that
warns about perfectly correct code.

-- 
                The choice of a       Deliantra, the free code+content MORPG
      -----==-     _GNU_              http://www.deliantra.net
      ----==-- _       generation
      ---==---(_)__  __ ____  __      Marc Lehmann
      --==---/ / _ \/ // /\ \/ /      schm...@schmorp.de
      -=====/_/_//_/\_,_/ /_/\_\

_______________________________________________
libev mailing list
libev@lists.schmorp.de
http://lists.schmorp.de/mailman/listinfo/libev

Reply via email to