librdkafka icon indicating copy to clipboard operation
librdkafka copied to clipboard

rdkafkacpp: Fix all -Wsuggest-override warnings

Open Quuxplusone opened this issue 3 years ago • 6 comments

Then, also in this branch:

  • rdkafkacpp: Remove an unused non-virtual function.

The non-virtual function has the same name as a bunch of virtual functions, and so I'm guessing that it was an oversight — it meant to override something from the base class, but in fact there was nothing to override with that particular signature, so it's simply an unused (dead) function.

Quuxplusone avatar Sep 06 '22 18:09 Quuxplusone

Gentle ping! and question: what's the best way to deal with the current test failure, which indicates that you can't use override in C++98 mode? I'd argue that C++98 is 24 years and 5 revisions-of-the-language ago, and it'd be fine to drop support for it now. But one could also add

#if __cplusplus >= 201103L
 #define RDKAFKA_OVERRIDE override
#else
 #define RDKAFKA_OVERRIDE
#endif

somewhere near the top of rdkafkacpp_int.h (and optionally #undef it at the bottom).

Quuxplusone avatar Sep 30 '22 13:09 Quuxplusone

Older MSVC toolchains typically have very old C++/C standard version support, so we need to be conservative with requiring modern things. So I'd prefer the ifdef approach.

edenhill avatar Oct 03 '22 12:10 edenhill

Updated! I named the new macro RD_OVERRIDE for consistency with RD_EXPORT. clang-format seems mostly happy with it; I tried also adding AttributeMacros: ['RD_OVERRIDE'] to the clang-format file, but that (A) seemed maybe unnecessary and (B) made the CI unhappy because its version of clang-format is pretty old.

At some future point, when C++11 support can be assumed, someone can make a PR that's just s/RD_OVERRIDE/override/g.

Quuxplusone avatar Oct 11 '22 19:10 Quuxplusone

Rebased — post-Thanksgiving ping!

I think it would be nice to add -Wsuggest-override to the project's default CXXFLAGS as well (when Clang is being used), just to avoid regressions in this department. But a brief glance at https://github.com/edenhill/librdkafka/blob/master/mklove/modules/configure.good_cflags did not enlighten me as to how to conditionally add something to CXXFLAGS (since not all compilers support -Wsuggest-override), so I'll leave that idea out-of-scope for now.

Quuxplusone avatar Nov 29 '22 16:11 Quuxplusone

CLA assistant check
All committers have signed the CLA.

cla-assistant[bot] avatar Aug 21 '23 15:08 cla-assistant[bot]

Ping!

Quuxplusone avatar Jan 11 '24 16:01 Quuxplusone