https://bz.apache.org/bugzilla/show_bug.cgi?id=63961

            Bug ID: 63961
           Summary: Examples in Developing Modules guide don't compile
                    with clang 4.x+
           Product: Apache httpd-2
           Version: 2.5-HEAD
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Documentation
          Assignee: docs@httpd.apache.org
          Reporter: yaneurab...@gmail.com
  Target Milestone: ---

While trying to address build warnings with a custom Apache module, I was
looking at the Developing Modules guide to see whether or not I could glean
information on how to fix the warnings with the module.

Turns out, there are some errors that needed to be addressed with the
documentation.

In particular, this section's
(https://httpd.apache.org/docs/2.4/developer/modguide.html#basics ) information
is incorrect/misleading, in the following ways:

module AP_MODULE_DECLARE_DATA   example_module =
{ 
    STANDARD20_MODULE_STUFF,
    create_dir_conf, /* Per-directory configuration handler */
    merge_dir_conf,  /* Merge handler for per-directory configurations */
    create_svr_conf, /* Per-server configuration handler */
    merge_svr_conf,  /* Merge handler for per-server configurations */
    directives,      /* Any directives we may have for httpd */
    register_hooks   /* Our hook registering function */
};

I discovered that there's an additional field needs to be defined in the
`AP_MODULE_DECLARE_DATA` struct:

module AP_MODULE_DECLARE_DATA   example_module =
{ 
    STANDARD20_MODULE_STUFF,
    create_dir_conf, /* Per-directory configuration handler */
    merge_dir_conf,  /* Merge handler for per-directory configurations */
    create_svr_conf, /* Per-server configuration handler */
    merge_svr_conf,  /* Merge handler for per-server configurations */
    directives,      /* Any directives we may have for httpd */
    register_hooks,  /* Our hook registering function */
    AP_MODULE_FLAG_NONE /* <-- HERE */
};

Another thing that didn't work with clang 4.0 is discussed in
https://httpd.apache.org/docs/2.4/developer/modguide.html#register_directive :

static const command_rec        example_directives[] =
{
    AP_INIT_TAKE1("exampleEnabled", example_set_enabled, NULL, RSRC_CONF,
"Enable or disable mod_example"),
    AP_INIT_TAKE1("examplePath", example_set_path, NULL, RSRC_CONF, "The path
to whatever"),
    AP_INIT_TAKE2("exampleAction", example_set_action, NULL, RSRC_CONF,
"Special action value!"),
    { NULL }
};

In particular, the sentinel at the end needs to instead be an nul set with
clang 4.0, since `command_rec` is not composed of a single element:

static const command_rec        example_directives[] =
{
    AP_INIT_TAKE1("exampleEnabled", example_set_enabled, NULL, RSRC_CONF,
"Enable or disable mod_example"),
    AP_INIT_TAKE1("examplePath", example_set_path, NULL, RSRC_CONF, "The path
to whatever"),
    AP_INIT_TAKE2("exampleAction", example_set_action, NULL, RSRC_CONF,
"Special action value!"),
    { } /* <-- HERE */
};

These fixes might not be 100% portable with other compliers, so additional
steps might need to be taken, depending on how conformant compilers are or
aren't when it comes to C99, etc.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: docs-unsubscr...@httpd.apache.org
For additional commands, e-mail: docs-h...@httpd.apache.org

Reply via email to