Skip to content

Release builds fail to compile due to unused variable #3545

@electricbrass

Description

@electricbrass

When trying to build libwebsockets, it fails in lib/core/context.c due to an unused variable. This seems to only occur on release builds. On debug builds, there is no issue.

[cmake] /home/mia/source/odamex/libraries/libwebsockets/lib/core/context.c:1765:20: error: ‘cname’ defined but not used [-Werror=unused-variable]
[cmake]  1765 | static const char *cname[] = { "Unknown", "OK", "Captive", "No internet" };
[cmake]       |                    ^~~~~

In my case LWS_WITH_SYS_STATE is disabled, as is LWS_WITH_NO_LOGS.

#if (defined(LWS_WITH_SYS_STATE) && defined(LWS_WITH_SYS_SMD)) || !defined(LWS_WITH_NO_LOGS)
static const char *cname[] = { "Unknown", "OK", "Captive", "No internet" };
#endif

As far as I can tell, that means cname is defined, and is used only a few lines later:

#if !defined(LWS_WITH_NO_LOGS)
lwsl_cx_info(cx, "setting CPD result %s", cname[result]);
#endif

So I don't understand why there would be an error for it being unused.

I am using v4.5.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions