diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index ef6fc19f60..68925c68c0 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -28,6 +28,7 @@ OPTION(ENABLE_BUILD_OPTIMIZATIONS "Enable certain compiler and linker optimizati OPTION(USE_IFC4 "Use IFC 4 instead of IFC 2x3 (full rebuild recommended when switching this)" OFF) OPTION(BUILD_IFCPYTHON "Build IfcPython." ON) OPTION(BUILD_EXAMPLES "Build example applications." ON) +OPTION(USE_VLC "Use Visual Leak Detector for debugging memory leaks, MSVC-only." OFF) # TODO QtViewer is deprecated ATM as it uses the 0.4 API # OPTION(BUILD_QTVIEWER "Build IfcOpenShell Qt GUI Viewer (requires Qt 4 framework)." OFF) @@ -237,6 +238,9 @@ if(ENABLE_BUILD_OPTIMIZATIONS) endif() IF(MSVC) + IF(USE_VLC) + ADD_DEFINITIONS(-DUSE_VLC) + ENDIF() # Enforce Unicode for CRT and Win32 API calls ADD_DEFINITIONS(-D_UNICODE -DUNICODE) # Disable warnings about unsafe C functions; we could use the safe C99 & C11 versions if we have no need for supporting old compilers. diff --git a/src/examples/IfcOpenHouse.cpp b/src/examples/IfcOpenHouse.cpp index af9de2bebe..ce811161e7 100644 --- a/src/examples/IfcOpenHouse.cpp +++ b/src/examples/IfcOpenHouse.cpp @@ -41,6 +41,10 @@ #include "../ifcparse/IfcHierarchyHelper.h" #include "../ifcgeom/IfcGeom.h" +#if USE_VLC +#include +#endif + // Some convenience typedefs and definitions. typedef std::string S; typedef IfcParse::IfcGlobalId guid; @@ -531,6 +535,8 @@ void createGroundShape(TopoDS_Shape& shape) { TColStd_Array1OfInteger mult(0, 1); mult(0) = 5; mult(1) = 5; +#undef new + Handle(Geom_BSplineSurface) surf = new Geom_BSplineSurface(cv, knots, knots, mult, mult, 4, 4); #if OCC_VERSION_HEX < 0x60502 shape = BRepBuilderAPI_MakeFace(surf); diff --git a/src/examples/IfcParseExamples.cpp b/src/examples/IfcParseExamples.cpp index 342a6e8674..1d418ee628 100644 --- a/src/examples/IfcParseExamples.cpp +++ b/src/examples/IfcParseExamples.cpp @@ -19,6 +19,10 @@ #include "../ifcparse/IfcFile.h" +#if USE_VLC +#include +#endif + using namespace IfcSchema; int main(int argc, char** argv) { diff --git a/src/ifcconvert/IfcConvert.cpp b/src/ifcconvert/IfcConvert.cpp index 73ecb1ad95..da8184acb7 100644 --- a/src/ifcconvert/IfcConvert.cpp +++ b/src/ifcconvert/IfcConvert.cpp @@ -46,6 +46,10 @@ #include #include +#if USE_VLC +#include +#endif + static std::string DEFAULT_EXTENSION = "obj"; void printVersion() { diff --git a/src/ifcgeomserver/IfcGeomServer.cpp b/src/ifcgeomserver/IfcGeomServer.cpp index fa3a356b4d..3ba7cedb82 100644 --- a/src/ifcgeomserver/IfcGeomServer.cpp +++ b/src/ifcgeomserver/IfcGeomServer.cpp @@ -37,6 +37,10 @@ #include "../ifcgeom/IfcGeomIterator.h" +#if USE_VLC +#include +#endif + using namespace boost; template @@ -282,7 +286,13 @@ public: Bye() : Command(BYE) {}; }; -int main () { +int main () +{ + // Memory leak debugging in MSVC debug mode +#if defined(_MSC_VER) && defined(_DEBUG) + _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); +#endif + // Redirect stdout to this stream, so that involuntary // writes to stdout do not interfere with our protocol. std::ostringstream oss;