Fix MSVC++ compile error caused by missing round() in math.h

This commit is contained in:
Mark Morschhäuser 2014-03-11 16:10:55 +01:00
parent 6e9f81461a
commit 80da61dcbb
8 changed files with 37 additions and 6 deletions

View file

@ -82,6 +82,7 @@ SET(cockatrice_SOURCES
${CMAKE_CURRENT_BINARY_DIR}/version_string.cpp
)
SET(cockatrice_HEADERS
src/round.h
src/abstractcounter.h
src/counter_general.h
src/dlg_creategame.h

View file

@ -2,7 +2,10 @@
#include <QGraphicsScene>
#include <QCursor>
#include <QGraphicsSceneMouseEvent>
#include <math.h>
#include <cmath>
#ifdef _WIN32
#include "round.h"
#endif /* _WIN32 */
#include "carddatabase.h"
#include "cardinfowidget.h"
#include "abstractcarditem.h"

View file

@ -3,7 +3,10 @@
#include <QPen>
#include <QTimer>
#include <QDebug>
#include <math.h>
#include <cmath>
#ifdef _WIN32
#include "round.h"
#endif /* _WIN32 */
#include "phasestoolbar.h"
#include "pixmapgenerator.h"

View file

@ -2,7 +2,10 @@
#include "pb/serverinfo_user.pb.h"
#include <QPainter>
#include <QSvgRenderer>
#include <math.h>
#include <cmath>
#ifdef _WIN32
#include "round.h"
#endif /* _WIN32 */
#include <QDebug>
QMap<QString, QPixmap> PhasePixmapGenerator::pmCache;

View file

@ -5,7 +5,10 @@
#include <QPainter>
#include <QPixmapCache>
#include <QDebug>
#include <math.h>
#include <cmath>
#ifdef _WIN32
#include "round.h"
#endif /* _WIN32 */
PlayerCounter::PlayerCounter(Player *_player, int _id, const QString &_name, int _value, QGraphicsItem *parent)
: AbstractCounter(_player, _id, _name, false, _value, parent)

View file

@ -2,7 +2,10 @@
#include <QPainter>
#include <QPalette>
#include <QTimer>
#include <math.h>
#include <cmath>
#ifdef _WIN32
#include "round.h"
#endif /* _WIN32 */
ReplayTimelineWidget::ReplayTimelineWidget(QWidget *parent)
: QWidget(parent), maxBinValue(1), maxTime(1), timeScaleFactor(1.0), currentTime(0), currentEvent(0)

12
cockatrice/src/round.h Normal file
View file

@ -0,0 +1,12 @@
#ifndef MSVC_ROUND_FIX
#define MSVC_ROUND_FIX
/**
* This helper function exists only because MS VC++ 2010 does not support round() in
* <cmath>. round() works with g++ and clang++ but is formally a C++11 extension.
* So this file exists for MS VC++ only.
*/
inline double round(double val) {
return floor(val + 0.5);
}
#endif /* MSVC_ROUND_FIX */

View file

@ -1,7 +1,10 @@
#include <QPainter>
#include <QSet>
#include <QGraphicsScene>
#include <math.h>
#include <cmath>
#ifdef _WIN32
#include "round.h"
#endif /* _WIN32 */
#include "tablezone.h"
#include "player.h"
#include "settingscache.h"