Skip to content

c++ warning unused parameter ‘j’ for empty object #2362

Description

@elionne

I have this minimal json schema:

{
  "type": "object",
  "additionalProperties": false
}

which render as following code:

// ...
    struct Nop {};

    inline void from_json(const json & j, Nop& x) {}

    inline void to_json(json & j, const Nop & x) {
        j = json::object();
    }

The compiler raise warning about j or x are not used. And since I use the -Werror option, it turns into an error.

I can use #pragma GCC diagnostic … to change compiler warning behavior, but it is not satisfying and not portable. It will be better if the generated code does not create any warning.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions