quicktype icon indicating copy to clipboard operation
quicktype copied to clipboard

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

Open elionne opened this issue 2 years ago • 0 comments

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.

elionne avatar Aug 09 '23 09:08 elionne