On Tue, Sep 6, 2016 at 2:07 PM,  <yla...@apache.org> wrote:
> Author: ylavic
> Date: Tue Sep  6 12:07:39 2016
> New Revision: 1759415
>
> URL: http://svn.apache.org/viewvc?rev=1759415&view=rev
> Log:
> http_config: follow up to r1702948: maybe unused, yet maybe usefull too.

I get plenty of warnings compiling 2.4.x with recent gcc, like:

/home/yle/src/apache/httpd/2.4.x/include/http_config.h|429 col 24|
warning: ‘aplog_module_index’ defined but not used
[-Wunused-const-variable=]
||      static int * const aplog_module_index = &(foo##_module.module_index)
||                         ^
/home/yle/src/apache/httpd/2.4.x/include/http_config.h|446 col 5|
note: in expansion of macro ‘APLOG_USE_MODULE’
||      APLOG_USE_MODULE(foo);                         \
||      ^~~~~~~~~~~~~~~~
/home/yle/src/apache/asf/httpd/httpd/branches/2.4.x/server/core.c|5314
col 1| note: in expansion of macro ‘AP_DECLARE_MODULE’
||  AP_DECLARE_MODULE(core) = {
||  ^~~~~~~~~~~~~~~~~

with several modules.

Maybe we could backport r1702948 (and this commit, which I think is a
better naming for the attribute) ?

Alternatively, if AP_MAYBE_UNUSED looks too (compiler) specific, the
following works for me too...

@@ -424,7 +426,11 @@ struct module_struct {
  */
 #define APLOG_USE_MODULE(foo) \
     extern module AP_MODULE_DECLARE_DATA foo##_module;                  \
-    static int * const aplog_module_index = &(foo##_module.module_index)
+    static int * const aplog_module_index = &(foo##_module.module_index); \
+    static APR_INLINE int aplog_foo##_module_index(void)                  \
+    {                                                                     \
+        return aplog_module_index ? *aplog_module_index : -1;             \
+    }

This makes the static variable used in an inline function, which
itself may be unused but compilers do not warn about this
(usually...).

WDYT?

Reply via email to