[Kde-games-devel] Re: KGameRenderer compile fails on Mac OS X

Ian Wadham iandw.au at gmail.com
Wed Jul 27 05:03:03 CEST 2011


Hi Stefan,

Thanks for your prompt reply.  It's an issue that is bothering not just
me but also at least one guy who does Macports of KDE apps.

On 25/07/2011, at 11:45 PM, Stefan Majewsky wrote:
> I think this is https://bugs.kde.org/show_bug.cgi?id=261488

It certainly looks like that.  BTW the fix suggested in the last comment on
that bug works fine: extra parentheses around QHash<QColor, QColor>()
in kgamerenderer.h:211 and kgamerenderer_p.h:36.  IME language specs,
compiler implementations or one's own memory are sometimes ambiguous
re details of precedence rules, so it never hurts to stick in extra parentheses
and make one's own intentions perfectly clear.  See patch at end of this email.

> The qHash function for QColor is at kgamerenderer.h:34-40. Otherwise
> it would not have compiled on Linux gcc. I am absolutely puzzled why
> the Mac C++ compiler rejects it. (Judging from the error messages, it
> seems to be gcc. Could you verify that?)

It is gcc, but which version is hard to tell.  AFAICT from CMakeCache.txt,
CMake has CMAKE_CXX_COMPILER:FILEPATH=/usr/bin/c++ and
/usr/bin/c++ --version says i686-apple-darwin10-g++-4.2.1 (GCC) 4.2.1.

There have been some issues lately, in the Macports community, re gcc.
The consensus seems to be to use "clang" (yes, that *is* the name of a
compiler, produced by Apple, see http://en.wikipedia.org/wiki/Clang ).
Otherwise use a more recent version of gcc provided by Macports or
even a Macports version of "clang".  Macports has gcc in versions
4.2.4, 4.3.6, 4.4.6, 4.5.3 and 4.6 beta.  These are for use with various
versions of Apple OS X.

Compilers on Apple are strange beasts.  Apple uses Objective-C in its
software and there is now a thing called Objective-C++, a hybrid.  Qt-mac
contains pieces of Objective-C++, i.e. interspersed C, C++ and Objective-C
code because it uses Apple OS X libraries for the gui.

> Could you try to:
> 
> 1. insert "typedef QHash<QColor, QColor> QColorHash" before the
> KGameRenderer class (after the qHash stuff) and replace usages
> accordingly and see if that helps?

Nope.  Same compiler error-messages.

> 2. explicitly instantiate the template by putting "template class
> QHash<QColor, QColor>;" before the KGameRenderer class (after the
> qHash stuff) and see if that helps or how the error messages change?

Same error-messages again.  I think the extra parentheses are the
way to go ... :-)  See below.

All the best, Ian W.

Index: kgamerenderer_p.h
===================================================================
--- kgamerenderer_p.h   (revision 1242828)
+++ kgamerenderer_p.h   (working copy)
@@ -33,7 +33,7 @@
        //Describes the state of a KGameRendererClient.
        struct ClientSpec
        {
-               inline ClientSpec(const QString& spriteKey = QString(), int frame = -1, const QSize& size = QSize(), const QHash<QColor, QColor>& customColors = QHash<QColor, QColor>());
+               inline ClientSpec(const QString& spriteKey = QString(), int frame = -1, const QSize& size = QSize(), const QHash<QColor, QColor>& customColors = (QHash<QColor, QColor>()));
                QString spriteKey;
                int frame;
                QSize size;
Index: kgamerenderer.h
===================================================================
--- kgamerenderer.h     (revision 1242828)
+++ kgamerenderer.h     (working copy)
@@ -208,7 +208,7 @@
                ///@note  For non-animated frames, set @a frame to -1 or omit it.
                ///@note  Custom colors increase the rendering time considerably, so use
                ///       this feature only if you really need its flexibility.
-               QPixmap spritePixmap(const QString& key, const QSize& size, int frame = -1, const QHash<QColor, QColor>& customColors = QHash<QColor, QColor>()) const;
+               QPixmap spritePixmap(const QString& key, const QSize& size, int frame = -1, const QHash<QColor, QColor>& customColors = (QHash<QColor, QColor>())) const;
        public Q_SLOTS:
                ///Load the given theme and update the pixmaps of all associated
                ///KGameRendererClient instances.



More information about the kde-games-devel mailing list