Skip to content

Commit

Permalink
+ Better support of clang, fix issues discovered by clang
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed May 5, 2014
1 parent 3b6d078 commit 2d4110b
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 35 deletions.
8 changes: 6 additions & 2 deletions CMakeLists.txt
Expand Up @@ -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)
configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
add_definitions(-DHAVE_CONFIG_H)
Expand All @@ -55,7 +59,7 @@ if(CMAKE_COMPILER_IS_GNUCXX)
if(UNIX)
# SET(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined")
endif(UNIX)
endif(CMAKE_COMPILER_IS_GNUCXX)
endif(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX)


# ================================================================================
Expand Down
5 changes: 3 additions & 2 deletions src/Base/UnitsSchema.h
Expand Up @@ -23,7 +23,7 @@

#ifndef BASE_UNITSSCHEMA_H
#define BASE_UNITSSCHEMA_H



#include <string>
#include <QString>
Expand All @@ -50,6 +50,7 @@ enum UnitSystem {
class UnitsSchema
{
public:
virtual ~UnitsSchema(){}
/** get called if this schema gets activated.
* Here its theoretical possible that you can change the static factors
* for certain Units (e.g. mi = 1,8km instead of mi=1.6km).
Expand All @@ -59,7 +60,7 @@ class UnitsSchema
virtual void resetSchemaUnits(void){}

/// 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;
};


Expand Down
2 changes: 2 additions & 0 deletions src/Base/Vector3D.cpp
Expand Up @@ -411,5 +411,7 @@ void Vector3<_Precision>::TransformToCoordinateSystem (const Vector3 &rclBase,
}

// explicit template instantiation
namespace Base {
template class BaseExport Vector3<float>;
template class BaseExport Vector3<double>;
}
33 changes: 17 additions & 16 deletions src/Gui/Selection.h
Expand Up @@ -88,20 +88,20 @@ class GuiExport SelectionChanges
// 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.)
//
// 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:
// 'explicit instantiation of 'class Base::Subject<const Gui::SelectionChanges&>'
// 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
// 'explicit instantiation of 'class Base::Subject<const Gui::SelectionChanges&>'
// 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
// 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

#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))
#if GNUC_VERSION >= 0x040100 && GNUC_VERSION < 0x040400
template class GuiExport Base::Subject<const Gui::SelectionChanges&>;
#endif
template class GuiExport Base::Subject<const Gui::SelectionChanges&>;
#endif
#undef GNUC_VERSION
#endif

Expand Down Expand Up @@ -130,11 +130,11 @@ class GuiExport SelectionObserver
void detachSelection();

private:
virtual void onSelectionChanged(const SelectionChanges& msg) = 0;

private:
typedef boost::signals::connection Connection;
Connection connectSelection;
virtual void onSelectionChanged(const SelectionChanges& msg) = 0;

private:
typedef boost::signals::connection Connection;
Connection connectSelection;
};

/**
Expand All @@ -156,7 +156,7 @@ class GuiExport SelectionObserverPython : public SelectionObserver
static void removeObserver(const Py::Object& obj);

private:
void onSelectionChanged(const SelectionChanges& msg);
void onSelectionChanged(const SelectionChanges& msg);
void addSelection(const SelectionChanges&);
void removeSelection(const SelectionChanges&);
void setSelection(const SelectionChanges&);
Expand All @@ -165,8 +165,8 @@ class GuiExport SelectionObserverPython : public SelectionObserver
void removePreselection(const SelectionChanges&);

private:
Py::Object inst;
static std::vector<SelectionObserverPython*> _instances;
Py::Object inst;
static std::vector<SelectionObserverPython*> _instances;
};

/** SelectionGate
Expand All @@ -176,6 +176,7 @@ class GuiExport SelectionObserverPython : public SelectionObserver
class SelectionGate
{
public:
virtual ~SelectionGate(){}
virtual bool allow(App::Document*,App::DocumentObject*, const char*)=0;
};

Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Fem/Gui/TaskObjectName.cpp
Expand Up @@ -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&)));

if(pcObject->Label.getValue() != "")
if(strcmp(pcObject->Label.getValue(),"") != 0)
ui->lineEdit_ObjectName->setText(QString::fromUtf8(pcObject->Label.getValue()));
else
ui->lineEdit_ObjectName->setText(QString::fromAscii(pcObject->getNameInDocument()));
Expand Down
6 changes: 3 additions & 3 deletions src/Mod/Mesh/App/Core/Iterator.h
Expand Up @@ -27,7 +27,7 @@
#include "MeshKernel.h"
#include "Elements.h"
#include <Base/Matrix.h>
#include <Base/Vector3D.h>
#include <Base/Vector3D.h>
#include <climits>

namespace MeshCore {
Expand Down Expand Up @@ -382,7 +382,7 @@ inline MeshFacetIterator& MeshFacetIterator::operator = (const MeshFacetIterator
_bApply = rpI._bApply;
_clTrf = rpI._clTrf;
// dirty flat copy of reference
memcpy((void*)&_rclMesh, &rpI._rclMesh, sizeof(&_rclMesh));
memcpy((void*)&_rclMesh, &rpI._rclMesh, sizeof(MeshKernel*));
return *this;
}

Expand Down Expand Up @@ -470,7 +470,7 @@ inline MeshPointIterator& MeshPointIterator::operator = (const MeshPointIterator
_bApply = rpI._bApply;
_clTrf = rpI._clTrf;
// dirty flat copy of reference
memcpy((void*)&_rclMesh, &rpI._rclMesh, sizeof(&_rclMesh));
memcpy((void*)&_rclMesh, &rpI._rclMesh, sizeof(MeshKernel*));
return *this;
}

Expand Down
20 changes: 10 additions & 10 deletions src/Mod/Mesh/App/MeshPyImp.cpp
Expand Up @@ -1031,11 +1031,11 @@ PyObject* MeshPy::splitEdge(PyObject *args)

const MeshCore::MeshKernel& kernel = getMeshObjectPtr()->getKernel();
PY_TRY {
if (facet < 0 || facet >= kernel.CountFacets()) {
if (facet >= kernel.CountFacets()) {
PyErr_SetString(PyExc_IndexError, "Facet index out of range");
return NULL;
}
if (neighbour < 0 || neighbour >= kernel.CountFacets()) {
if (neighbour >= kernel.CountFacets()) {
PyErr_SetString(PyExc_IndexError, "Facet index out of range");
return NULL;
}
Expand Down Expand Up @@ -1072,7 +1072,7 @@ PyObject* MeshPy::splitFacet(PyObject *args)

const MeshCore::MeshKernel& kernel = getMeshObjectPtr()->getKernel();
PY_TRY {
if (facet < 0 || facet >= kernel.CountFacets()) {
if (facet >= kernel.CountFacets()) {
PyErr_SetString(PyExc_IndexError, "Facet index out of range");
return NULL;
}
Expand All @@ -1091,11 +1091,11 @@ PyObject* MeshPy::swapEdge(PyObject *args)

const MeshCore::MeshKernel& kernel = getMeshObjectPtr()->getKernel();
PY_TRY {
if (facet < 0 || facet >= kernel.CountFacets()) {
if (facet >= kernel.CountFacets()) {
PyErr_SetString(PyExc_IndexError, "Facet index out of range");
return NULL;
}
if (neighbour < 0 || neighbour >= kernel.CountFacets()) {
if (neighbour >= kernel.CountFacets()) {
PyErr_SetString(PyExc_IndexError, "Facet index out of range");
return NULL;
}
Expand All @@ -1121,11 +1121,11 @@ PyObject* MeshPy::collapseEdge(PyObject *args)

const MeshCore::MeshKernel& kernel = getMeshObjectPtr()->getKernel();
PY_TRY {
if (facet < 0 || facet >= kernel.CountFacets()) {
if (facet >= kernel.CountFacets()) {
PyErr_SetString(PyExc_IndexError, "Facet index out of range");
return NULL;
}
if (neighbour < 0 || neighbour >= kernel.CountFacets()) {
if (neighbour >= kernel.CountFacets()) {
PyErr_SetString(PyExc_IndexError, "Facet index out of range");
return NULL;
}
Expand All @@ -1150,7 +1150,7 @@ PyObject* MeshPy::collapseFacet(PyObject *args)
return NULL;

PY_TRY {
if (facet < 0 || facet >= getMeshObjectPtr()->countFacets()) {
if (facet >= getMeshObjectPtr()->countFacets()) {
PyErr_SetString(PyExc_IndexError, "Facet index out of range");
return NULL;
}
Expand All @@ -1173,7 +1173,7 @@ PyObject* MeshPy::insertVertex(PyObject *args)
Base::Vector3f v((float)val->x,(float)val->y,(float)val->z);

PY_TRY {
if (facet < 0 || facet >= getMeshObjectPtr()->countFacets()) {
if (facet >= getMeshObjectPtr()->countFacets()) {
PyErr_SetString(PyExc_IndexError, "Facet index out of range");
return NULL;
}
Expand All @@ -1196,7 +1196,7 @@ PyObject* MeshPy::snapVertex(PyObject *args)
Base::Vector3f v((float)val->x,(float)val->y,(float)val->z);

PY_TRY {
if (facet < 0 || facet >= getMeshObjectPtr()->countFacets()) {
if (facet >= getMeshObjectPtr()->countFacets()) {
PyErr_SetString(PyExc_IndexError, "Facet index out of range");
return NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Raytracing/Gui/Command.cpp
Expand Up @@ -558,7 +558,7 @@ CmdRaytracingRender::CmdRaytracingRender()
void CmdRaytracingRender::activated(int iMsg)
{
// determining render type
const char* renderType;
std::string renderType;
unsigned int n1 = getSelection().countObjectsOfType(Raytracing::RayProject::getClassTypeId());
if (n1 != 1) {
unsigned int n2 = getSelection().countObjectsOfType(Raytracing::LuxProject::getClassTypeId());
Expand Down

0 comments on commit 2d4110b

Please sign in to comment.