google / emboss

Emboss is a tool for generating code that reads and writes binary data structures.
Apache License 2.0
68 stars 21 forks source link

Clang Wunused-parameter warning #69

Closed BenjaminLawson closed 1 year ago

BenjaminLawson commented 1 year ago

On a project where Wunused-parameter warnings are errors, I encountered the following build error:

hci.emb.h:43695:24: error: unused parameter 'emboss_reserved_local_value' [-Werror,-Wunused-parameter]
        ::std::int32_t emboss_reserved_local_value) {

I have a temporary fix of using the Wno-unused-parameter flag on targets that depend on Emboss, but this is not ideal.

I'm not 100% sure, but I think this can be fixed by just wrapping the parameter name in an inline comment.

reventlov commented 1 year ago

That's probably on one of the ValueIsOk() methods at generated_code_templates:472 and 661.

It's actually a bit tricky to figure out when the parameter name should be omitted/commented out, but an easier fix is to put an explicit cast to void at the top of the method:

static constexpr bool ValueIsOk(
    $_logical_type_$ emboss_reserved_local_value) {
  (void)emboss_reserved_local_value;
  return $_value_is_ok_$.ValueOr(false);
}

I can probably set up a PR in the next (work) day or two.