Skip to content
Permalink
Browse files
Applied patch from David Willis for msvc/win32 build support
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@7226 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux committed Sep 27, 2007
1 parent b406f1d commit c7dba658e70620998fde1e6549bb39a2677db8dd
@@ -145,6 +145,17 @@ IF (WIN32)
SET (QGIS_PLUGIN_DIR ${CMAKE_INSTALL_PREFIX}/plugins)
SET (QGIS_INCLUDE_DIR ${CMAKE_INSTALL_PREFIX}/include)
SET (QGIS_SOURCE_DIR ${CMAKE_SOURCE_DIR})
IF(MSVC)
# Turn on defines for non standard maths stuff
ADD_DEFINITIONS(-D_USE_MATH_DEFINES)

# Some file access stuff not defined in native win32
# environment
ADD_DEFINITIONS(-DF_OK=0)
ADD_DEFINITIONS(-DX_OK=1)
ADD_DEFINITIONS(-DW_OK=2)
ADD_DEFINITIONS(-DR_OK=4)
ENDIF(MSVC)

ELSE (WIN32)

@@ -7,11 +7,11 @@ FIND_PROGRAM(SVNVERSION svnversion)

# Read the version if installed, else set to "unknown"
IF (SVNVERSION)
EXEC_PROGRAM(${SVNVERSION} ARGS @CMAKE_CURRENT_SOURCE_DIR@ OUTPUT_VARIABLE MYVERSION)
EXEC_PROGRAM(${SVNVERSION} ARGS "@CMAKE_CURRENT_SOURCE_DIR@" OUTPUT_VARIABLE MYVERSION)
ELSE (SVNVERSION)
SET(MYVERSION unknown)
ENDIF (SVNVERSION)

# Configure the qgssvnversion.h
CONFIGURE_FILE(@CMAKE_CURRENT_SOURCE_DIR@/cmake_templates/qgssvnversion.h.in_cmake
@CMAKE_CURRENT_BINARY_DIR@/qgssvnversion.h)
CONFIGURE_FILE("@CMAKE_CURRENT_SOURCE_DIR@/cmake_templates/qgssvnversion.h.in_cmake"
"@CMAKE_CURRENT_BINARY_DIR@/qgssvnversion.h")
@@ -30,6 +30,10 @@
#include <QPainter>
#include <iostream>
#include <cmath>
// round isn't defined by default in msvc
#ifdef _MSC_VER
#define round(x) ((x) >= 0 ? floor((x)+0.5) : floor((x)-0.5))
#endif

QgsComposerMap::QgsComposerMap ( QgsComposition *composition, int id, int x, int y, int width, int height )
: QWidget(), QGraphicsRectItem(0,0,width,height,0)
@@ -83,7 +83,13 @@ class QTreeWidgetItem;
class QgsLegend : public QTreeWidget
{
Q_OBJECT;

private:
// Moved here to match access of declaration later in file.
// Previous location raised a warning in msvc as the forward
// declaration was public while the definition was private
class QgsLegendPixmaps;


public:
/*! Constructor.
* @param qgis_app link to qgisapp
@@ -169,7 +175,6 @@ class QgsLegend : public QTreeWidget
/**Sets the toggle editing action. Usually called from QgisApp*/
void setToggleEditingAction(QAction* editingAction){mToggleEditingAction = editingAction;}

class QgsLegendPixmaps;
/**Returns structure with legend pixmaps*/
QgsLegendPixmaps& pixmaps() { return mPixmaps; }

@@ -44,6 +44,13 @@
#include <fcntl.h> /* _O_BINARY */
#undef _fmode
int _fmode = _O_BINARY;
#ifndef _MSC_VER
// Only do this if we are not building on windows with msvc.
// Recommended method for doing this with msvc is with a call to _set_fmode
// which is the first thing we do in main().
#undef _fmode
int _fmode = _O_BINARY;
#endif//_MSC_VER
#else
#include <getopt.h>
#endif
@@ -216,6 +223,9 @@ void myMessageOutput( QtMsgType type, const char *msg )

int main(int argc, char *argv[])
{
#ifdef _MSC_VER
_set_fmode(_O_BINARY);
#endif

// Set up the custom qWarning/qDebug custom handler
qInstallMsgHandler( myMessageOutput );
@@ -114,10 +114,10 @@ class CORE_EXPORT QgsApplication: public QApplication
*/
static QString reportStyleSheet();
private:
CORE_EXPORT static QString mPrefixPath;
CORE_EXPORT static QString mPluginPath;
CORE_EXPORT static QString mPkgDataPath;
CORE_EXPORT static QString mThemePath;
static QString mPrefixPath;
static QString mPluginPath;
static QString mPkgDataPath;
static QString mThemePath;
};

#endif
@@ -170,7 +170,12 @@ bool Tools::Geometry::LineSegment::touchesShape(const IShape& s) const

void Tools::Geometry::LineSegment::getCenter(Point& out) const
{
#ifdef _MSC_VER
// MSVC doesn't like non-const array initialisers
double* coords = new double[m_dimension];
#else
double coords[m_dimension];
#endif//_MSC_VER

for (unsigned long cDim = 0; cDim < m_dimension; cDim++)
{
@@ -180,6 +185,10 @@ void Tools::Geometry::LineSegment::getCenter(Point& out) const
}

out = Point(coords, m_dimension);

#ifdef _MSC_VER
delete[] coords;
#endif//_MSC_VER
}

unsigned long Tools::Geometry::LineSegment::getDimension() const
@@ -189,8 +198,14 @@ unsigned long Tools::Geometry::LineSegment::getDimension() const

void Tools::Geometry::LineSegment::getMBR(Region& out) const
{
#ifdef _MSC_VER
// MSVC doesn't like non-const array initialisers
double* low = new double[m_dimension];
double* high = new double[m_dimension];
#else
double low[m_dimension];
double high[m_dimension];
#endif//_MSC_VER

for (unsigned long cDim = 0; cDim < m_dimension; cDim++)
{
@@ -199,6 +214,11 @@ void Tools::Geometry::LineSegment::getMBR(Region& out) const
}

out = Region(low, high, m_dimension);

#ifdef _MSC_VER
delete[] low;
delete[] high;
#endif//_MSC_VER
}

double Tools::Geometry::LineSegment::getArea() const
@@ -70,7 +70,13 @@ namespace SpatialIndex
unsigned long m_dataLength;
}; // Data

#ifdef _MSC_VER
// MSVC didn't like the difference in parameter names between declaration
// definition
extern ISpatialIndex* returnRTree(IStorageManager& sm, Tools::PropertySet& ps);
#else
extern ISpatialIndex* returnRTree(IStorageManager& in, Tools::PropertySet& in);
#endif//_MSC_VER
extern ISpatialIndex* createNewRTree(
IStorageManager& sm,
double fillFactor,
@@ -183,7 +183,13 @@ namespace SpatialIndex
extern IStorageManager* createNewDiskStorageManager(std::string& baseName, unsigned long pageSize);
extern IStorageManager* loadDiskStorageManager(std::string& baseName);

#ifdef _MSC_VER
// MSVC didn't like the difference in parameter names between declaration
// definition
extern IBuffer* returnRandomEvictionsBuffer(IStorageManager& sm, Tools::PropertySet& ps);
#else
extern IBuffer* returnRandomEvictionsBuffer(IStorageManager& in, Tools::PropertySet& in);
#endif//_MSC_VER
extern IBuffer* createNewRandomEvictionsBuffer(IStorageManager& in, unsigned int capacity, bool bWriteThrough);
}

@@ -22,6 +22,10 @@
#ifndef __tools_h
#define __tools_h

#ifdef _MSC_VER
#include <locale>
#include <limits>
#endif//_MSC_VER
#include <stdint.h>
#include <assert.h>
#include <iostream>
@@ -402,10 +406,19 @@ namespace Tools
private:
std::map<std::string, Variant> m_propertySet;

#ifdef _MSC_VER
// MSVC's friend function syntax differs slightly from everyone elses:
// don't seem to need to qualify function name.
friend std::ostream& operator<<(
std::ostream& os,
const Tools::PropertySet& p
);
#else
friend std::ostream& Tools::operator<<(
std::ostream& os,
const Tools::PropertySet& p
);
#endif//_MSC_VER
}; // PropertySet

std::ostream& operator<<(std::ostream& os, const Tools::PropertySet& p);
@@ -606,10 +619,19 @@ namespace Tools
unsigned long long* m_a;
unsigned long m_k;

#ifdef _MSC_VER
// MSVC's friend function syntax differs slightly from everyone elses
// don't seem to need to qualify function name.
friend std::ostream& operator<<(
std::ostream& os,
const Tools::UniversalHash& h
);
#else
friend std::ostream& Tools::operator<<(
std::ostream& os,
const Tools::UniversalHash& h
);
#endif//_MSC_VER
}; // UniversalHash

std::ostream& operator<<(std::ostream& os, const Tools::UniversalHash& h);
@@ -224,7 +224,12 @@ void BulkLoader::TmpFile::rewind()
}

void BulkLoader::bulkLoadUsingSTR(
#ifdef _MSC_VER
// MSVC seems to find RTree* pTree ambiguous
SpatialIndex::RTree::RTree* pTree,
#else
RTree* pTree,
#endif//_MSC_VER
IDataStream& stream,
unsigned long bindex,
unsigned long bleaf,
@@ -277,7 +282,12 @@ void BulkLoader::bulkLoadUsingSTR(
}

void BulkLoader::createLevel(
#ifdef _MSC_VER
// MSVC seems to find RTree* pTree ambiguous
SpatialIndex::RTree::RTree* pTree,
#else
RTree* pTree,
#endif//_MSC_VER
Tools::IObjectStream& stream,
unsigned long dimension,
unsigned long k,
@@ -340,7 +350,12 @@ void BulkLoader::createLevel(
}
}

#ifdef _MSC_VER
// MSVC seems to find RTree* pTree ambiguous
Node* BulkLoader::createNode(SpatialIndex::RTree::RTree* pTree, std::vector<Tools::SmartPointer<IData> >& e, unsigned long level)
#else
Node* BulkLoader::createNode(RTree* pTree, std::vector<Tools::SmartPointer<IData> >& e, unsigned long level)
#endif//_MSC_VER
{
Node* n;

@@ -35,7 +35,12 @@ Index::~Index()
{
}

#ifdef _MSC_VER
// MSVC seems to find RTree* pTree ambiguous
Index::Index(SpatialIndex::RTree::RTree* pTree, long id, unsigned long level) : Node(pTree, id, level, pTree->m_indexCapacity)
#else
Index::Index(RTree* pTree, long id, unsigned long level) : Node(pTree, id, level, pTree->m_indexCapacity)
#endif//_MSC_VER
{
}

@@ -35,7 +35,12 @@ Leaf::~Leaf()
{
}

#ifdef _MSC_VER
// MSVC seems to find RTree* pTree ambiguous
Leaf::Leaf(SpatialIndex::RTree::RTree* pTree, long id): Node(pTree, id, 0, pTree->m_leafCapacity)
#else
Leaf::Leaf(RTree* pTree, long id): Node(pTree, id, 0, pTree->m_leafCapacity)
#endif//_MSC_VER
{
}

@@ -217,7 +217,12 @@ Node::Node() :
{
}

Node::Node(RTree* pTree, long id, unsigned long level, unsigned long capacity) :
#ifdef _MSC_VER
// MSVC seems to find RTree* pTree ambiguous
Node::Node(SpatialIndex::RTree::RTree* pTree, long id, unsigned long level, unsigned long capacity) :
#else
Node::Node(RTree* pTree, long id, unsigned long level, unsigned long capacity) :
#endif//_MSC_VER
m_pTree(pTree),
m_level(level),
m_identifier(id),
@@ -29,6 +29,9 @@

#ifdef WIN32
#include <io.h>
#ifdef _MSC_VER
#include <basetsd.h>
#endif//_MSC_VER
#define fsync(fd) _commit(fd)
#endif

@@ -39,6 +42,10 @@ using namespace SpatialIndex::StorageManager;
using std::map;
using std::vector;

#ifdef _MSC_VER
typedef SSIZE_T ssize_t;
#endif//_MSC_VER

SpatialIndex::IStorageManager* SpatialIndex::StorageManager::returnDiskStorageManager(Tools::PropertySet& ps)
{
IStorageManager* sm = new DiskStorageManager(ps);

0 comments on commit c7dba65

Please sign in to comment.