Warning displayed using `override` in c++ header on Windows
This post is to raise the issue upstream, gexiv2 can use the workaround listed below.
Problem
While modernising a C++ class to use override
and removing the redundant virtual
, a warning was generated on Windows 10 with MinGW64 (MinGW/MSYS2) but not on Linux. The original commit can be found in the gexiv2 project here.
The warning message is
$ ninja -C build/meson.debug.win32.x86_64/ install
### <SNIP>
Building documentation for gexiv2
C:/Users/user/gexiv2_postscript-dev/gexiv2/gexiv2-stream-io.h:0: warning: partial declaration (function) : ) override;
int close () override;
size_type write (const Exiv2::byte* data, size_type wcount) override;
size_type write (Exiv2::BasicIo& src) override;
int putb (Exiv2::byte data) override;
#if EXIV2_TEST_VERSION(0,27,99)
Exiv2::DataBuf read (size_t rcount) noexcept override;
#else
Exiv2::DataBuf read (long rcount) override;
#endif
size_type read (Exiv2::byte* buf, size_type rcount) override;
int getb () override;
void transfer (Exiv2::BasicIo& src) override;
int seek (long offset, Position pos) override;
Exiv2::byte* mmap (bool isWriteable = false) override;
int munmap () override;
long tell () const override;
size_t size () const override;
bool isopen () const override;
int error () const override;
bool eof () const override;
std::string path () const override;
#ifdef EXV_UNICODE_PATH
std::wstring wpath () const override;
#endif
ptr_type temporary () const;
private:
/* stream callbacks */
ManagedStreamCallbacks* cb;
/* used for mmap and munmap */
ptr_type memio;
/* closing does not mean closing the stream, because this would
destroy it. So just keep track about current state and let stream
open. */
gboolean is_open;
/* stream can be used for writing */
gboolean can_write;
};
#endif /* GEXIV2_STREAM_IO_H */
### <SNIP>
Further Information
The problem is connected to the use of the virtual
keyword, as removing this changes whether the warning is shown.
- Use
override
withoutvirtual
= Warning - Use
override
withvirtual
= OK - Use
virtual
withoutoverride
= OK
As best I understand it, C++11 does not require the use of virtual
in this particular case.
Software Versions
- gtk-doc: 1.33.2-1
- meson: 0.56.2-1
- ninja: 1.10.2-1
- gcc: 10.2.0-6
- clang: 11.0.0-7
- All installed packages are up to date
Possible Workaround
If a class is not included in the generated documentation then the warning can be removed by changing the meson.build
file and adding the appropriate ignore_headers
entry to the gnome.gtkdoc()
.