+ Better support of clang, fix issues discovered by clang

This commit is contained in:
wmayer 2014-05-05 18:25:59 +02:00
parent 3b6d07833d
commit 2d4110b0f3
8 changed files with 43 additions and 35 deletions

View File

@ -45,7 +45,11 @@ endif(WIN32)
# ================================================================================ # ================================================================================
if(CMAKE_COMPILER_IS_GNUCXX) if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
set(CMAKE_COMPILER_IS_CLANGXX TRUE)
endif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX)
include(cMake/ConfigureChecks.cmake) include(cMake/ConfigureChecks.cmake)
configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h) configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
add_definitions(-DHAVE_CONFIG_H) add_definitions(-DHAVE_CONFIG_H)
@ -55,7 +59,7 @@ if(CMAKE_COMPILER_IS_GNUCXX)
if(UNIX) if(UNIX)
# SET(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined") # SET(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined")
endif(UNIX) endif(UNIX)
endif(CMAKE_COMPILER_IS_GNUCXX) endif(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX)
# ================================================================================ # ================================================================================

View File

@ -23,7 +23,7 @@
#ifndef BASE_UNITSSCHEMA_H #ifndef BASE_UNITSSCHEMA_H
#define BASE_UNITSSCHEMA_H #define BASE_UNITSSCHEMA_H
#include <string> #include <string>
#include <QString> #include <QString>
@ -50,6 +50,7 @@ enum UnitSystem {
class UnitsSchema class UnitsSchema
{ {
public: public:
virtual ~UnitsSchema(){}
/** get called if this schema gets activated. /** get called if this schema gets activated.
* Here its theoretical possible that you can change the static factors * Here its theoretical possible that you can change the static factors
* for certain Units (e.g. mi = 1,8km instead of mi=1.6km). * for certain Units (e.g. mi = 1,8km instead of mi=1.6km).
@ -59,7 +60,7 @@ public:
virtual void resetSchemaUnits(void){} virtual void resetSchemaUnits(void){}
/// this methode translate the quantity in a string as the user may expect it /// this methode translate the quantity in a string as the user may expect it
virtual QString schemaTranslate(Base::Quantity quant,double &factor,QString &unitString)=0; virtual QString schemaTranslate(Base::Quantity quant,double &factor,QString &unitString)=0;
}; };

View File

@ -411,5 +411,7 @@ void Vector3<_Precision>::TransformToCoordinateSystem (const Vector3 &rclBase,
} }
// explicit template instantiation // explicit template instantiation
namespace Base {
template class BaseExport Vector3<float>; template class BaseExport Vector3<float>;
template class BaseExport Vector3<double>; template class BaseExport Vector3<double>;
}

View File

@ -88,20 +88,20 @@ public:
// Export an instance of the base class (to avoid warning C4275, see also // Export an instance of the base class (to avoid warning C4275, see also
// C++ Language Reference/General Rules and Limitations on MSDN for more details.) // C++ Language Reference/General Rules and Limitations on MSDN for more details.)
// //
// For compiler gcc4.1 we need to define the template class outside namespace 'Gui' // For compiler gcc4.1 we need to define the template class outside namespace 'Gui'
// otherwise we get the compiler error: // otherwise we get the compiler error:
// 'explicit instantiation of 'class Base::Subject<const Gui::SelectionChanges&>' // 'explicit instantiation of 'class Base::Subject<const Gui::SelectionChanges&>'
// in namespace 'Gui' (which does not enclose namespace 'Base') // in namespace 'Gui' (which does not enclose namespace 'Base')
// //
// It seems that this costruct is not longer needed for gcc4.4 and even leads to // It seems that this costruct is not longer needed for gcc4.4 and even leads to
// errors under Mac OS X. Thus, we check for version between 4.1 and 4.4. // errors under Mac OS X. Thus, we check for version between 4.1 and 4.4.
// It seems that for Mac OS X this can be completely ignored // It seems that for Mac OS X this can be completely ignored
#if defined(__GNUC__) && defined(__GNUC_MINOR__) && !defined(FC_OS_MACOSX) #if defined(__GNUC__) && defined(__GNUC_MINOR__) && !defined(FC_OS_MACOSX)
#define GNUC_VERSION (((__GNUC__)<<16)+((__GNUC_MINOR__)<<8)) #define GNUC_VERSION (((__GNUC__)<<16)+((__GNUC_MINOR__)<<8))
#if GNUC_VERSION >= 0x040100 && GNUC_VERSION < 0x040400 #if GNUC_VERSION >= 0x040100 && GNUC_VERSION < 0x040400
template class GuiExport Base::Subject<const Gui::SelectionChanges&>; template class GuiExport Base::Subject<const Gui::SelectionChanges&>;
#endif #endif
#undef GNUC_VERSION #undef GNUC_VERSION
#endif #endif
@ -130,11 +130,11 @@ public:
void detachSelection(); void detachSelection();
private: private:
virtual void onSelectionChanged(const SelectionChanges& msg) = 0; virtual void onSelectionChanged(const SelectionChanges& msg) = 0;
private: private:
typedef boost::signals::connection Connection; typedef boost::signals::connection Connection;
Connection connectSelection; Connection connectSelection;
}; };
/** /**
@ -156,7 +156,7 @@ public:
static void removeObserver(const Py::Object& obj); static void removeObserver(const Py::Object& obj);
private: private:
void onSelectionChanged(const SelectionChanges& msg); void onSelectionChanged(const SelectionChanges& msg);
void addSelection(const SelectionChanges&); void addSelection(const SelectionChanges&);
void removeSelection(const SelectionChanges&); void removeSelection(const SelectionChanges&);
void setSelection(const SelectionChanges&); void setSelection(const SelectionChanges&);
@ -165,8 +165,8 @@ private:
void removePreselection(const SelectionChanges&); void removePreselection(const SelectionChanges&);
private: private:
Py::Object inst; Py::Object inst;
static std::vector<SelectionObserverPython*> _instances; static std::vector<SelectionObserverPython*> _instances;
}; };
/** SelectionGate /** SelectionGate
@ -176,6 +176,7 @@ private:
class SelectionGate class SelectionGate
{ {
public: public:
virtual ~SelectionGate(){}
virtual bool allow(App::Document*,App::DocumentObject*, const char*)=0; virtual bool allow(App::Document*,App::DocumentObject*, const char*)=0;
}; };

View File

@ -60,7 +60,7 @@ TaskObjectName::TaskObjectName(App::DocumentObject *pcObject,QWidget *parent)
QObject::connect(ui->lineEdit_ObjectName,SIGNAL(textChanged (const QString&)),this,SLOT(TextChanged(const QString&))); QObject::connect(ui->lineEdit_ObjectName,SIGNAL(textChanged (const QString&)),this,SLOT(TextChanged(const QString&)));
if(pcObject->Label.getValue() != "") if(strcmp(pcObject->Label.getValue(),"") != 0)
ui->lineEdit_ObjectName->setText(QString::fromUtf8(pcObject->Label.getValue())); ui->lineEdit_ObjectName->setText(QString::fromUtf8(pcObject->Label.getValue()));
else else
ui->lineEdit_ObjectName->setText(QString::fromAscii(pcObject->getNameInDocument())); ui->lineEdit_ObjectName->setText(QString::fromAscii(pcObject->getNameInDocument()));

View File

@ -27,7 +27,7 @@
#include "MeshKernel.h" #include "MeshKernel.h"
#include "Elements.h" #include "Elements.h"
#include <Base/Matrix.h> #include <Base/Matrix.h>
#include <Base/Vector3D.h> #include <Base/Vector3D.h>
#include <climits> #include <climits>
namespace MeshCore { namespace MeshCore {
@ -382,7 +382,7 @@ inline MeshFacetIterator& MeshFacetIterator::operator = (const MeshFacetIterator
_bApply = rpI._bApply; _bApply = rpI._bApply;
_clTrf = rpI._clTrf; _clTrf = rpI._clTrf;
// dirty flat copy of reference // dirty flat copy of reference
memcpy((void*)&_rclMesh, &rpI._rclMesh, sizeof(&_rclMesh)); memcpy((void*)&_rclMesh, &rpI._rclMesh, sizeof(MeshKernel*));
return *this; return *this;
} }
@ -470,7 +470,7 @@ inline MeshPointIterator& MeshPointIterator::operator = (const MeshPointIterator
_bApply = rpI._bApply; _bApply = rpI._bApply;
_clTrf = rpI._clTrf; _clTrf = rpI._clTrf;
// dirty flat copy of reference // dirty flat copy of reference
memcpy((void*)&_rclMesh, &rpI._rclMesh, sizeof(&_rclMesh)); memcpy((void*)&_rclMesh, &rpI._rclMesh, sizeof(MeshKernel*));
return *this; return *this;
} }

View File

@ -1031,11 +1031,11 @@ PyObject* MeshPy::splitEdge(PyObject *args)
const MeshCore::MeshKernel& kernel = getMeshObjectPtr()->getKernel(); const MeshCore::MeshKernel& kernel = getMeshObjectPtr()->getKernel();
PY_TRY { PY_TRY {
if (facet < 0 || facet >= kernel.CountFacets()) { if (facet >= kernel.CountFacets()) {
PyErr_SetString(PyExc_IndexError, "Facet index out of range"); PyErr_SetString(PyExc_IndexError, "Facet index out of range");
return NULL; return NULL;
} }
if (neighbour < 0 || neighbour >= kernel.CountFacets()) { if (neighbour >= kernel.CountFacets()) {
PyErr_SetString(PyExc_IndexError, "Facet index out of range"); PyErr_SetString(PyExc_IndexError, "Facet index out of range");
return NULL; return NULL;
} }
@ -1072,7 +1072,7 @@ PyObject* MeshPy::splitFacet(PyObject *args)
const MeshCore::MeshKernel& kernel = getMeshObjectPtr()->getKernel(); const MeshCore::MeshKernel& kernel = getMeshObjectPtr()->getKernel();
PY_TRY { PY_TRY {
if (facet < 0 || facet >= kernel.CountFacets()) { if (facet >= kernel.CountFacets()) {
PyErr_SetString(PyExc_IndexError, "Facet index out of range"); PyErr_SetString(PyExc_IndexError, "Facet index out of range");
return NULL; return NULL;
} }
@ -1091,11 +1091,11 @@ PyObject* MeshPy::swapEdge(PyObject *args)
const MeshCore::MeshKernel& kernel = getMeshObjectPtr()->getKernel(); const MeshCore::MeshKernel& kernel = getMeshObjectPtr()->getKernel();
PY_TRY { PY_TRY {
if (facet < 0 || facet >= kernel.CountFacets()) { if (facet >= kernel.CountFacets()) {
PyErr_SetString(PyExc_IndexError, "Facet index out of range"); PyErr_SetString(PyExc_IndexError, "Facet index out of range");
return NULL; return NULL;
} }
if (neighbour < 0 || neighbour >= kernel.CountFacets()) { if (neighbour >= kernel.CountFacets()) {
PyErr_SetString(PyExc_IndexError, "Facet index out of range"); PyErr_SetString(PyExc_IndexError, "Facet index out of range");
return NULL; return NULL;
} }
@ -1121,11 +1121,11 @@ PyObject* MeshPy::collapseEdge(PyObject *args)
const MeshCore::MeshKernel& kernel = getMeshObjectPtr()->getKernel(); const MeshCore::MeshKernel& kernel = getMeshObjectPtr()->getKernel();
PY_TRY { PY_TRY {
if (facet < 0 || facet >= kernel.CountFacets()) { if (facet >= kernel.CountFacets()) {
PyErr_SetString(PyExc_IndexError, "Facet index out of range"); PyErr_SetString(PyExc_IndexError, "Facet index out of range");
return NULL; return NULL;
} }
if (neighbour < 0 || neighbour >= kernel.CountFacets()) { if (neighbour >= kernel.CountFacets()) {
PyErr_SetString(PyExc_IndexError, "Facet index out of range"); PyErr_SetString(PyExc_IndexError, "Facet index out of range");
return NULL; return NULL;
} }
@ -1150,7 +1150,7 @@ PyObject* MeshPy::collapseFacet(PyObject *args)
return NULL; return NULL;
PY_TRY { PY_TRY {
if (facet < 0 || facet >= getMeshObjectPtr()->countFacets()) { if (facet >= getMeshObjectPtr()->countFacets()) {
PyErr_SetString(PyExc_IndexError, "Facet index out of range"); PyErr_SetString(PyExc_IndexError, "Facet index out of range");
return NULL; return NULL;
} }
@ -1173,7 +1173,7 @@ PyObject* MeshPy::insertVertex(PyObject *args)
Base::Vector3f v((float)val->x,(float)val->y,(float)val->z); Base::Vector3f v((float)val->x,(float)val->y,(float)val->z);
PY_TRY { PY_TRY {
if (facet < 0 || facet >= getMeshObjectPtr()->countFacets()) { if (facet >= getMeshObjectPtr()->countFacets()) {
PyErr_SetString(PyExc_IndexError, "Facet index out of range"); PyErr_SetString(PyExc_IndexError, "Facet index out of range");
return NULL; return NULL;
} }
@ -1196,7 +1196,7 @@ PyObject* MeshPy::snapVertex(PyObject *args)
Base::Vector3f v((float)val->x,(float)val->y,(float)val->z); Base::Vector3f v((float)val->x,(float)val->y,(float)val->z);
PY_TRY { PY_TRY {
if (facet < 0 || facet >= getMeshObjectPtr()->countFacets()) { if (facet >= getMeshObjectPtr()->countFacets()) {
PyErr_SetString(PyExc_IndexError, "Facet index out of range"); PyErr_SetString(PyExc_IndexError, "Facet index out of range");
return NULL; return NULL;
} }

View File

@ -558,7 +558,7 @@ CmdRaytracingRender::CmdRaytracingRender()
void CmdRaytracingRender::activated(int iMsg) void CmdRaytracingRender::activated(int iMsg)
{ {
// determining render type // determining render type
const char* renderType; std::string renderType;
unsigned int n1 = getSelection().countObjectsOfType(Raytracing::RayProject::getClassTypeId()); unsigned int n1 = getSelection().countObjectsOfType(Raytracing::RayProject::getClassTypeId());
if (n1 != 1) { if (n1 != 1) {
unsigned int n2 = getSelection().countObjectsOfType(Raytracing::LuxProject::getClassTypeId()); unsigned int n2 = getSelection().countObjectsOfType(Raytracing::LuxProject::getClassTypeId());