Files
nethack/win/Qt/qt_pre.h
nhmall 6c61004b06 g++-12 bits, mostly Qt5 related
I forced a test compile to -std=c++20 mostly to see what we would
be up against. There was only a small number of things and they
are corrected in this commit.

c++20 has some issues with comparisons and bit twiddling between
different enums.

The vendor-supplied Qt5 header files triggered some of those issues as
well, so the qt_pre.h and qt_post.h NetHack header files were adjusted
to make those new warnings go away.  I have not tested Qt6 under the
new compiler and c++ version yet.

Because there are multiple pragmas in qt_pre.h now, the conditional
ifdef structure in there was modified a little to make maintenance
simpler and have a single pragma push at the top. The pragma pop
comes after the Qt vendor-supplied header files, and is done
in qt_post.h.

The display.h macro cmap_to_glyph() was used in
a Qt c++ file and triggered a series of warnings because of that.
Rather than write c++20-friendly versions of those macros, the
simple fix is to provide a function on the C side of things
to front the cmap_to_glyph() macro, so fn_cmap_to_glyph()
was added.

Also thrown into this commit, PatR picked up on the fact that for
yesterday's new warning in qt_menu.cpp, the compiler had correctly
picked up on the fact that the format range of the variable 'cash'
had been correctly upper-capped at 999999999L in the warning message
because of an assignment prior. He suggested that perhaps by also adding
    if (cash < 0)
       cash = 0;
the warning might be eliminated altogether.
After a test, that was proven to be correct, so yesterday's
more-kludgy change is reverted and replaced with that variable
variable restriction ahead of the snprintf().
2022-06-11 13:52:58 -04:00

71 lines
1.7 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/* NetHack 3.7 qt_pre.h $NHDT-Date: 1597276835 2020/08/13 00:00:35 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.0 $ */
/*
* qt_pre.h -- undefine some nethack macros which conflict with Qt headers.
*
* #include after "hack.h", before <Qt.../Qt...>.
*/
#undef C // conflicts with Qt6 header
#undef Invisible
#undef Warning
#undef index
#undef msleep
#undef rindex
#undef wizard
#undef yn
#undef min
#undef max
#if defined(__cplusplus)
#ifdef __clang__
#pragma clang diagnostic push
#endif
#ifdef __GNUC__
#pragma GCC diagnostic push
#endif
/* the diagnostic pop is in qt_post.h */
#ifdef __clang__
/* disable warnings for shadowed names; some of the Qt prototypes use
placeholder argument names which conflict with nethack variables
('g', 'u', a couple of others) */
#pragma clang diagnostic ignored "-Wshadow"
#elif defined(__GNUC__)
#pragma GCC diagnostic ignored "-Wshadow"
#endif
#include <QtGlobal>
/* QFontMetrics::width was deprecated in Qt 5.11 */
#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)
#define QFM_WIDTH(foo) width(foo)
#else
#define QFM_WIDTH(foo) horizontalAdvance(foo)
#endif
#if __cplusplus >= 202002L
/* c++20 or newer */
#if QT_VERSION < 0x060000
/*
* qt5/QtWidgets/qsizepolicy.h
* Qt5 header file issue under c++ 20
*
* warning: bitwise operation between different enumeration types
* QSizePolicy::Policy and QSizePolicy::PolicyFlag
* is deprecated [-Wdeprecated-enum-enum-conversion]
*/
#if defined(__GNUC__)
#pragma GCC diagnostic ignored "-Wdeprecated-enum-enum-conversion"
#endif
#if defined(__clang__)
#pragma clang diagnostic ignored "-Wdeprecated-enum-enum-conversion"
#endif
#endif /* QT_VERSION < 0x060000 */
#endif /* __cplusplus >= 202002L */
#endif /* __cplusplus */
/*qt_pre.h*/