From baeb918de4603740aa021e97970b6caad1d222c1 Mon Sep 17 00:00:00 2001 From: abv Date: Fri, 11 Oct 2019 22:04:02 +0300 Subject: [PATCH] 0031060: Configuration - Support building with CLang compiler under VS 2019 Build tools are updated to support building with Visual Studion 2019 toolset ClangCL (LLVM clang-cl): - In CMake builds, use of unsupported option "-std=c++0x" is avoided - Tool genconf recognizes availability of ClangCL toolset and proposes it in the list - Tool genproj recognizes new compiler specification VCVER=vclang and generates VS 2019 projects for it Note that vclang configuration puts binaries to folder "vc14" as it is compatible with vc14 CRT. Code is updated to build with Clang for Windows without errors and warnings: - In BVH classes, pure virtual destructors are replaced by empty ones, to avoid bogus compiler warning - In .lex files, pragmas are added to disable warnings in parser code - In OSD, signature of function _osd_wnt_set_error() is corrected to avoid warning on incorrect use of va_args (undefined behavior) - In OSD_Host, OSD_Parallel_TBB, warnings on usage of deprecated function are disabled - In Quantity_ColorRGBA and ViewerTest_CmdParser, incorrect use of predefined macro __FUNCTION__ assuming it was a string literal is avoided - In Standard_Macro.hxx, code is reordered to handle Clang for Windows appropriately - In AdvApp2Var_SysBase.hxx, inclusion of obsolete (MSVC-specific) header file is replaced by Standard_TypeDef.hxx - In BRepExtrema_SelfIntersection.hxx, missing Standard_EXPORT is added - In Standard_ErrorHandler.hxx, empty statements added to avoid warning on unused class fields - In IVtkDraw and ViewerTest, interface is corrected to use actual type avoiding unnecessary type casts Off-topic: corrections of some errors (uninitialized class fields) reported by VS Code Analysis in TKernel --- adm/cmake/occt_defs_flags.cmake | 4 +++- adm/genconf.tcl | 5 +++++ adm/genconfdeps.tcl | 12 ++++++++++-- adm/genproj.tcl | 12 +++++++++--- adm/templates/env.bat | 13 +++++++++++++ dox/overview/overview.md | 2 +- src/AdvApp2Var/AdvApp2Var_SysBase.hxx | 6 +----- src/BRepExtrema/BRepExtrema_SelfIntersection.hxx | 4 ++-- src/BVH/BVH_Object.hxx | 12 +----------- src/BVH/BVH_QueueBuilder.hxx | 12 +----------- src/BVH/BVH_Set.hxx | 12 +----------- src/ExprIntrp/ExprIntrp.lex | 4 ++++ src/ExprIntrp/lex.ExprIntrp.c | 4 ++++ src/IVtkDraw/IVtkDraw.cxx | 9 ++++----- src/IVtkDraw/IVtkDraw.hxx | 3 ++- src/IVtkDraw/IVtkDraw_Interactor.cxx | 4 ++++ src/NCollection/NCollection_AccAllocator.hxx | 4 ++-- src/NCollection/NCollection_SparseArrayBase.hxx | 4 ++-- src/OSD/OSD_Directory.cxx | 2 +- src/OSD/OSD_DirectoryIterator.cxx | 9 +++++++-- src/OSD/OSD_Disk.cxx | 2 +- src/OSD/OSD_File.cxx | 2 +- src/OSD/OSD_FileIterator.cxx | 9 +++++++-- src/OSD/OSD_FileNode.cxx | 4 ++-- src/OSD/OSD_Host.cxx | 12 +++--------- src/OSD/OSD_Parallel_TBB.cxx | 2 ++ src/OSD/OSD_Path.cxx | 5 +++-- src/OSD/OSD_Process.cxx | 2 +- src/OSD/OSD_Timer.cxx | 6 +++--- src/QABugs/QABugs_11.cxx | 4 ++-- src/QABugs/QABugs_19.cxx | 2 ++ src/Quantity/Quantity_ColorRGBA.cxx | 4 ++-- src/Standard/Standard_ErrorHandler.hxx | 2 ++ src/Standard/Standard_Macro.hxx | 6 +++--- src/StepFile/lex.step.c | 4 ++++ src/StepFile/step.lex | 5 +++++ src/Storage/Storage_Schema.cxx | 4 +++- src/ViewerTest/ViewerTest.hxx | 3 ++- src/ViewerTest/ViewerTest_CmdParser.cxx | 12 ++++++------ src/ViewerTest/ViewerTest_ViewerCommands.cxx | 9 ++++----- 40 files changed, 135 insertions(+), 101 deletions(-) diff --git a/adm/cmake/occt_defs_flags.cmake b/adm/cmake/occt_defs_flags.cmake index 5484c6759f..484002d1aa 100644 --- a/adm/cmake/occt_defs_flags.cmake +++ b/adm/cmake/occt_defs_flags.cmake @@ -130,7 +130,9 @@ elseif ("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xClang") if (APPLE) # CLang can be used with both libstdc++ and libc++, however on OS X libstdc++ is outdated. set (CMAKE_CXX_FLAGS "-std=c++0x -stdlib=libc++ ${CMAKE_CXX_FLAGS}") - else() + elseif(NOT WIN32) + # CLang for Windows (at least CLang 8.0 distributed with VS 2019) + # does not support option "-std=c++0x" set (CMAKE_CXX_FLAGS "-std=c++0x ${CMAKE_CXX_FLAGS}") endif() elseif (DEFINED CMAKE_COMPILER_IS_GNUCXX) diff --git a/adm/genconf.tcl b/adm/genconf.tcl index 88b17d46b7..799945e3ba 100644 --- a/adm/genconf.tcl +++ b/adm/genconf.tcl @@ -82,6 +82,11 @@ if { ! [catch {exec vswhere.exe -version "\[16.0,16.99\]" -latest -requires Micr lappend ::SYS_VC_LIST "vc142-uwp" lappend ::SYS_VCVARS_LIST "$res\\VC\\vcvarsall.bat" } +if { ! [catch {exec vswhere.exe -version "\[16.0,16.99\]" -latest -requires Microsoft.VisualStudio.Component.VC.ClangCL -property installationPath} res] } { + lappend ::SYS_VS_LIST "Visual Studio 2019 (16, toolset ClangCL)" + lappend ::SYS_VC_LIST "vclang" + lappend ::SYS_VCVARS_LIST "$res\\VC\\vcvarsall.bat" +} # detect installed Visual Studio instances from global environment if { [info exists ::env(VS140COMNTOOLS)] } { diff --git a/adm/genconfdeps.tcl b/adm/genconfdeps.tcl index 030879dc15..3897341ce2 100644 --- a/adm/genconfdeps.tcl +++ b/adm/genconfdeps.tcl @@ -241,7 +241,11 @@ proc wokdep:Preferred {theList theCmpl theArch} { # keep only two first digits in "vc141" if { ! [regexp {^vc[0-9][0-9]} $theCmpl aCmpl] } { - set aCmpl $theCmpl + if { [regexp {^vclang} $theCmpl] } { + set aCmpl vc14 + } else { + set aCmpl $theCmpl + } } set aShortList {} @@ -631,7 +635,11 @@ proc wokdep:SearchTBB {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64 # keep only two first digits in "vc141" if { ! [regexp {^vc[0-9][0-9]} ${::VCVER} aVcLib] } { - set aVcLib ${::VCVER} + if { [regexp {^vclang} ${::VCVER}] } { + set aVcLib vc14 + } else { + set aVcLib ${::VCVER} + } } set isFound "true" diff --git a/adm/genproj.tcl b/adm/genproj.tcl index 68f9871592..7e13b47e44 100644 --- a/adm/genproj.tcl +++ b/adm/genproj.tcl @@ -256,7 +256,7 @@ proc genAllResources {} { # Wrapper-function to generate VS project files proc genproj {theFormat args} { - set aSupportedFormats { "vc7" "vc8" "vc9" "vc10" "vc11" "vc12" "vc14" "vc141" "vc142" "cbp" "xcd" "pro"} + set aSupportedFormats { "vc7" "vc8" "vc9" "vc10" "vc11" "vc12" "vc14" "vc141" "vc142" "vclang" "cbp" "xcd" "pro"} set aSupportedPlatforms { "wnt" "uwp" "lin" "mac" "ios" "qnx" } set isHelpRequire false @@ -320,6 +320,7 @@ proc genproj {theFormat args} { vc14 - Visual Studio 2015 vc141 - Visual Studio 2017 vc142 - Visual Studio 2019 + vclang - Visual Studio with ClangCL toolset cbp - CodeBlocks xcd - XCode pro - Qt Creator @@ -529,7 +530,8 @@ proc OS:MKPRC { theOutDir theFormat theLibType thePlatform theCmpl theSolution } "vc12" - "vc14" - "vc141" - - "vc142" { OS:MKVC $anOutDir $aModules $theSolution $theFormat $isUWP} + "vc142" - + "vclang" { OS:MKVC $anOutDir $aModules $theSolution $theFormat $isUWP} "cbp" { OS:MKCBP $anOutDir $aModules $theSolution $thePlatform $theCmpl } "xcd" { set ::THE_GUIDS_LIST($::aTKNullKey) "000000000000000000000000" @@ -984,7 +986,8 @@ proc osutils:vcsolution:header { vcversion } { append var \ "Microsoft Visual Studio Solution File, Format Version 12.00\n" \ "# Visual Studio 2013\n" - } elseif { "$vcversion" == "vc14" || "$vcversion" == "vc141" || "$vcversion" == "vc142" } { + } elseif { "$vcversion" == "vc14" || "$vcversion" == "vc141" || + "$vcversion" == "vc142" || "$vcversion" == "vclang" } { append var \ "Microsoft Visual Studio Solution File, Format Version 12.00\n" \ "# Visual Studio 14\n" @@ -1225,6 +1228,9 @@ proc osutils:vcproj:readtemplate {theVcVer isUWP isExec} { } elseif { $theVcVer == "vc142" } { set aVCRTVer "vc14" set aToolset "v142" + } elseif { $theVcVer == "vclang" } { + set aVCRTVer "vc14" + set aToolset "ClangCL" } set what "$theVcVer" diff --git a/adm/templates/env.bat b/adm/templates/env.bat index 4180f23999..b262e10811 100644 --- a/adm/templates/env.bat +++ b/adm/templates/env.bat @@ -77,6 +77,9 @@ if "%VCVER:~-4%" == "-uwp" ( set VCLIB=%VCLIB%-uwp set VCPROP=Universal ) +if "%VCFMT%" == "vclang" ( + set VCLIB=vc14 +) rem echo VCVER=%VCVER% VCFMT=%VCFMT% VCLIB=%VCLIB% VCPROP=%VCPROP% rem ----- Parsing of Visual Studio platform ----- @@ -106,6 +109,10 @@ if not "%DevEnvDir%" == "" ( for /f "usebackq delims=" %%i in (`vswhere.exe -version "[16.0,16.99]" -latest -requires Microsoft.VisualStudio.Workload.%VCPROP% -property installationPath`) do ( set "DevEnvDir=%%i\Common7\IDE\" ) +) else if /I "%VCFMT%" == "vclang" ( + for /f "usebackq delims=" %%i in (`vswhere.exe -version "[16.0,16.99]" -latest -requires Microsoft.VisualStudio.Workload.%VCPROP% -property installationPath`) do ( + set "DevEnvDir=%%i\Common7\IDE\" + ) ) else if /I "%VCFMT%" == "gcc" ( rem MinGW ) else ( @@ -118,6 +125,7 @@ if not "%DevEnvDir%" == "" ( echo vc14 = VS 2015 echo vc141 = VS 2017 echo vc142 = VS 2019 + echo vclang = VS 2019 with ClangCL toolset exit /B ) @@ -147,6 +155,11 @@ if /I "%VCFMT%" == "vc9" ( set "VCVARS=%%i\VC\Auxiliary\Build\vcvarsall.bat" ) set "VCPlatformToolSet=v142" +) else if /I "%VCFMT%" == "vclang" ( + for /f "usebackq delims=" %%i in (`vswhere.exe -version "[16.0,16.99]" -latest -requires Microsoft.VisualStudio.Workload.%VCPROP% -property installationPath`) do ( + set "VCVARS=%%i\VC\Auxiliary\Build\vcvarsall.bat" + ) + set "VCPlatformToolSet=ClangCL" ) else if /I "%VCFMT%" == "gcc" ( rem MinGW ) else ( diff --git a/dox/overview/overview.md b/dox/overview/overview.md index 8115c90073..6ba96088a5 100644 --- a/dox/overview/overview.md +++ b/dox/overview/overview.md @@ -207,7 +207,7 @@ for which OCCT is certified to work. | OS | Compiler | | --------- | ----------- | -| Windows | Microsoft Visual Studio: 2008 SP1, 2010 SP1, 2012 Update 4, 2013 Update 5, 2015 Update 3, 2017 1, 2019
GCC 4.3+ (Mingw-w64)| +| Windows | Microsoft Visual Studio: 2008 SP1, 2010 SP1, 2012 Update 4, 2013 Update 5, 2015 Update 3, 2017 1, 2019
, LLVM (ClangCL), GCC 4.3+ (Mingw-w64)| | Linux | GNU gcc 4.3+
LLVM CLang 3.6+ | | OS X / macOS | XCode 6 or newer | | Android | NDK r10, GNU gcc 4.8 or newer | diff --git a/src/AdvApp2Var/AdvApp2Var_SysBase.hxx b/src/AdvApp2Var/AdvApp2Var_SysBase.hxx index 6f1c5330a4..135ec21fb1 100644 --- a/src/AdvApp2Var/AdvApp2Var_SysBase.hxx +++ b/src/AdvApp2Var/AdvApp2Var_SysBase.hxx @@ -16,12 +16,8 @@ #define AdvApp2Var_SysBase_HeaderFile #include +#include #include -#if _MSC_VER -#include -#else -#include -#endif class AdvApp2Var_SysBase { public: diff --git a/src/BRepExtrema/BRepExtrema_SelfIntersection.hxx b/src/BRepExtrema/BRepExtrema_SelfIntersection.hxx index b1cd1d98f7..0407abb3d3 100644 --- a/src/BRepExtrema/BRepExtrema_SelfIntersection.hxx +++ b/src/BRepExtrema/BRepExtrema_SelfIntersection.hxx @@ -96,8 +96,8 @@ public: protected: //! Filter out correct adjacent mesh elements. - virtual BRepExtrema_ElementFilter::FilterResult PreCheckElements (const Standard_Integer theIndex1, - const Standard_Integer theIndex2); + Standard_EXPORT virtual BRepExtrema_ElementFilter::FilterResult PreCheckElements (const Standard_Integer theIndex1, + const Standard_Integer theIndex2); //! Checks if the given triangles have only single common vertex. BRepExtrema_ElementFilter::FilterResult isRegularSharedVertex (const BVH_Vec3d& theSharedVert, diff --git a/src/BVH/BVH_Object.hxx b/src/BVH/BVH_Object.hxx index 82a9133f34..609169dd32 100644 --- a/src/BVH/BVH_Object.hxx +++ b/src/BVH/BVH_Object.hxx @@ -62,7 +62,7 @@ public: BVH_Object() {} //! Releases resources of geometric object. - virtual ~BVH_Object() = 0; + virtual ~BVH_Object() {} public: @@ -71,14 +71,4 @@ public: }; -// ======================================================================= -// function : ~BVH_Object -// purpose : -// ======================================================================= -template -BVH_Object::~BVH_Object() -{ - // -} - #endif // _BVH_Object_Header diff --git a/src/BVH/BVH_QueueBuilder.hxx b/src/BVH/BVH_QueueBuilder.hxx index c7c4bf34ec..51d79615dc 100644 --- a/src/BVH/BVH_QueueBuilder.hxx +++ b/src/BVH/BVH_QueueBuilder.hxx @@ -44,7 +44,7 @@ public: myNumOfThreads (theNumOfThreads) {} //! Releases resources of BVH queue based builder. - virtual ~BVH_QueueBuilder() = 0; + virtual ~BVH_QueueBuilder() {} public: @@ -288,14 +288,4 @@ void BVH_QueueBuilder::Build (BVH_Set* theSet, } } -// ======================================================================= -// function : ~BVH_QueueBuilder -// purpose : -// ======================================================================= -template -BVH_QueueBuilder::~BVH_QueueBuilder() -{ - // -} - #endif // _BVH_QueueBuilder_Header diff --git a/src/BVH/BVH_Set.hxx b/src/BVH/BVH_Set.hxx index 2d0950cb2b..aaec3f3272 100644 --- a/src/BVH/BVH_Set.hxx +++ b/src/BVH/BVH_Set.hxx @@ -35,7 +35,7 @@ public: BVH_Set() {} //! Releases resources of set of objects. - virtual ~BVH_Set() = 0; + virtual ~BVH_Set() {} //! Returns AABB of the entire set of objects. virtual BVH_Box Box() const @@ -67,14 +67,4 @@ public: }; -// ======================================================================= -// function : ~BVH_Set -// purpose : -// ======================================================================= -template -BVH_Set::~BVH_Set() -{ - // -} - #endif // _BVH_Set_Header diff --git a/src/ExprIntrp/ExprIntrp.lex b/src/ExprIntrp/ExprIntrp.lex index c2e2bc749a..e9f05243a3 100644 --- a/src/ExprIntrp/ExprIntrp.lex +++ b/src/ExprIntrp/ExprIntrp.lex @@ -57,6 +57,10 @@ static int yywrap() // Note that Intel compiler also defines _MSC_VER but has different warning ids #if defined(__INTEL_COMPILER) #pragma warning(disable:177 1786 1736) +#elif defined(__clang__) +#pragma GCC diagnostic ignored "-Wunused-function" +#pragma GCC diagnostic ignored "-Winconsistent-dllimport" +#pragma GCC diagnostic ignored "-Wunneeded-internal-declaration" #else #pragma warning(disable:4131 4244 4273 4127 4267) #endif diff --git a/src/ExprIntrp/lex.ExprIntrp.c b/src/ExprIntrp/lex.ExprIntrp.c index fa1f37beb1..c3593f9339 100644 --- a/src/ExprIntrp/lex.ExprIntrp.c +++ b/src/ExprIntrp/lex.ExprIntrp.c @@ -2106,6 +2106,10 @@ static int yywrap() // Note that Intel compiler also defines _MSC_VER but has different warning ids #if defined(__INTEL_COMPILER) #pragma warning(disable:177 1786 1736) +#elif defined(__clang__) +#pragma GCC diagnostic ignored "-Wunused-function" +#pragma GCC diagnostic ignored "-Winconsistent-dllimport" +#pragma GCC diagnostic ignored "-Wunneeded-internal-declaration" #else #pragma warning(disable:4131 4244 4273 4127 4267) #endif diff --git a/src/IVtkDraw/IVtkDraw.cxx b/src/IVtkDraw/IVtkDraw.cxx index 9c517db488..e3befa7f21 100644 --- a/src/IVtkDraw/IVtkDraw.cxx +++ b/src/IVtkDraw/IVtkDraw.cxx @@ -252,13 +252,13 @@ Standard_Integer GenerateId() // Function : WClass // Purpose : //========================================================= -const Handle(Standard_Transient)& IVtkDraw::WClass() +const Handle(WNT_WClass)& IVtkDraw::WClass() { - static Handle(Standard_Transient) aWindowClass; + static Handle(WNT_WClass) aWindowClass; #ifdef _WIN32 if (aWindowClass.IsNull()) { - aWindowClass = new WNT_WClass ("GWVTK_Class", DefWindowProc, + aWindowClass = new WNT_WClass ("GWVTK_Class", NULL, CS_VREDRAW | CS_HREDRAW, 0, 0, ::LoadCursorW (NULL, IDC_ARROW)); } @@ -305,8 +305,7 @@ void IVtkDraw::ViewerInit (Standard_Integer thePxLeft, #ifdef _WIN32 if (GetWindow().IsNull()) { - GetWindow() = new WNT_Window ("IVtkTest", - Handle(WNT_WClass)::DownCast (WClass()), + GetWindow() = new WNT_Window ("IVtkTest", WClass(), WS_OVERLAPPEDWINDOW, aPxLeft, aPxTop, aPxWidth, aPxHeight, diff --git a/src/IVtkDraw/IVtkDraw.hxx b/src/IVtkDraw/IVtkDraw.hxx index 6c485bea5e..2f7643a93a 100644 --- a/src/IVtkDraw/IVtkDraw.hxx +++ b/src/IVtkDraw/IVtkDraw.hxx @@ -21,6 +21,7 @@ #include class Draw_Interpretor; +class WNT_WClass; class IVtkDraw { @@ -37,7 +38,7 @@ public: Standard_EXPORT static void Commands (Draw_Interpretor& theCommands); private: - Standard_EXPORT static const Handle(Standard_Transient)& WClass(); + Standard_EXPORT static const Handle(WNT_WClass)& WClass(); }; #endif diff --git a/src/IVtkDraw/IVtkDraw_Interactor.cxx b/src/IVtkDraw/IVtkDraw_Interactor.cxx index 743caf9a39..0a3b90190b 100644 --- a/src/IVtkDraw/IVtkDraw_Interactor.cxx +++ b/src/IVtkDraw/IVtkDraw_Interactor.cxx @@ -187,6 +187,10 @@ void IVtkDraw_Interactor::Initialize() this->Size[1] = aSize[1]; } +#ifdef _WIN32 +LRESULT CALLBACK WndProc(HWND theHWnd, UINT theUMsg, WPARAM theWParam, LPARAM theLParam); +#endif + //=========================================================== // Function : Enable // Purpose : diff --git a/src/NCollection/NCollection_AccAllocator.hxx b/src/NCollection/NCollection_AccAllocator.hxx index ba716b8d71..239ba351c2 100644 --- a/src/NCollection/NCollection_AccAllocator.hxx +++ b/src/NCollection/NCollection_AccAllocator.hxx @@ -75,7 +75,7 @@ protected: { Standard_Size myValue; public: - AlignedSize(){} + AlignedSize() : myValue(0) {} AlignedSize(const Standard_Size theValue) : myValue((theValue + Align - 1) & ~(Align - 1)) {} operator Standard_Size() const {return myValue;} @@ -86,7 +86,7 @@ protected: { Standard_Byte* myValue; public: - AlignedPtr(){} + AlignedPtr() : myValue(0) {} AlignedPtr(const Standard_Address theValue) : myValue((Standard_Byte*)((Standard_Size)theValue & ~(Align - 1))) {} operator Standard_Address () const {return myValue;} diff --git a/src/NCollection/NCollection_SparseArrayBase.hxx b/src/NCollection/NCollection_SparseArrayBase.hxx index e5cbeff9db..ce5087d63b 100644 --- a/src/NCollection/NCollection_SparseArrayBase.hxx +++ b/src/NCollection/NCollection_SparseArrayBase.hxx @@ -190,8 +190,8 @@ public: private: // Copy constructor and assignment operator are private thus not accessible - NCollection_SparseArrayBase (const NCollection_SparseArrayBase&) {} - void operator = (const NCollection_SparseArrayBase&) {} + NCollection_SparseArrayBase(const NCollection_SparseArrayBase&); + void operator = (const NCollection_SparseArrayBase&); protected: // Object life diff --git a/src/OSD/OSD_Directory.cxx b/src/OSD/OSD_Directory.cxx index 5e4c90933d..589e5eac06 100644 --- a/src/OSD/OSD_Directory.cxx +++ b/src/OSD/OSD_Directory.cxx @@ -29,7 +29,7 @@ #include #endif - void _osd_wnt_set_error (OSD_Error&, OSD_WhoAmI, ... ); + void _osd_wnt_set_error (OSD_Error&, Standard_Integer, ... ); #else #include #include diff --git a/src/OSD/OSD_DirectoryIterator.cxx b/src/OSD/OSD_DirectoryIterator.cxx index 568122bb91..9e349588bc 100644 --- a/src/OSD/OSD_DirectoryIterator.cxx +++ b/src/OSD/OSD_DirectoryIterator.cxx @@ -193,7 +193,7 @@ Standard_Integer OSD_DirectoryIterator::Error()const{ #define _FD ( ( PWIN32_FIND_DATAW )myData ) -void _osd_wnt_set_error ( OSD_Error&, OSD_WhoAmI, ... ); +void _osd_wnt_set_error ( OSD_Error&, Standard_Integer, ... ); OSD_DirectoryIterator :: OSD_DirectoryIterator ( const OSD_Path& where, @@ -318,7 +318,12 @@ Standard_Integer OSD_DirectoryIterator :: Error () const { } // end OSD_DirectoryIterator :: Error // For compatibility with UNIX version -OSD_DirectoryIterator::OSD_DirectoryIterator() {} +OSD_DirectoryIterator::OSD_DirectoryIterator() +: myFlag(false), + myHandle(0), + myData(0), + myFirstCall(Standard_False) +{} void OSD_DirectoryIterator::Initialize( const OSD_Path&, diff --git a/src/OSD/OSD_Disk.cxx b/src/OSD/OSD_Disk.cxx index 0bd42fbe7c..ef37014bf8 100644 --- a/src/OSD/OSD_Disk.cxx +++ b/src/OSD/OSD_Disk.cxx @@ -25,7 +25,7 @@ #ifdef _WIN32 #include - void _osd_wnt_set_error (OSD_Error&, OSD_WhoAmI, ... ); + void _osd_wnt_set_error (OSD_Error&, Standard_Integer, ... ); static TCollection_AsciiString _osd_wnt_set_disk_name (const OSD_Path& thePath) { diff --git a/src/OSD/OSD_File.cxx b/src/OSD/OSD_File.cxx index cb4850f6da..b8c0abc43b 100644 --- a/src/OSD/OSD_File.cxx +++ b/src/OSD/OSD_File.cxx @@ -42,7 +42,7 @@ #define OPEN_OLD 1 #define OPEN_APPEND 2 - void _osd_wnt_set_error ( OSD_Error&, OSD_WhoAmI, ... ); + void _osd_wnt_set_error (OSD_Error&, Standard_Integer, ...); #ifndef OCCT_UWP PSECURITY_DESCRIPTOR __fastcall _osd_wnt_protection_to_sd ( const OSD_Protection&, BOOL, const wchar_t* ); diff --git a/src/OSD/OSD_FileIterator.cxx b/src/OSD/OSD_FileIterator.cxx index 7b8f469c91..d77ca7e84f 100644 --- a/src/OSD/OSD_FileIterator.cxx +++ b/src/OSD/OSD_FileIterator.cxx @@ -267,7 +267,7 @@ Standard_Integer OSD_FileIterator::Error()const{ #define _FD ( ( PWIN32_FIND_DATAW )myData ) -void _osd_wnt_set_error ( OSD_Error&, OSD_WhoAmI, ... ); +void _osd_wnt_set_error ( OSD_Error&, Standard_Integer, ... ); OSD_FileIterator :: OSD_FileIterator ( const OSD_Path& where, @@ -392,7 +392,12 @@ Standard_Integer OSD_FileIterator :: Error () const { } // end OSD_FileIterator :: Error // For compatibility with UNIX version -OSD_FileIterator::OSD_FileIterator() {} +OSD_FileIterator::OSD_FileIterator() +: myFlag(Standard_False), + myHandle(0), + myData(0), + myFirstCall(Standard_False) +{} void OSD_FileIterator::Initialize( const OSD_Path&, diff --git a/src/OSD/OSD_FileNode.cxx b/src/OSD/OSD_FileNode.cxx index 5155543808..f0444f717c 100644 --- a/src/OSD/OSD_FileNode.cxx +++ b/src/OSD/OSD_FileNode.cxx @@ -393,7 +393,7 @@ BOOL __fastcall _osd_wnt_sd_to_protection ( #endif Standard_Integer __fastcall _get_file_type ( Standard_CString, HANDLE ); -void _osd_wnt_set_error ( OSD_Error&, OSD_WhoAmI, ... ); +void _osd_wnt_set_error ( OSD_Error&, Standard_Integer, ... ); static BOOL __fastcall _get_file_time (const wchar_t*, LPSYSTEMTIME, BOOL ); static void __fastcall _test_raise ( TCollection_AsciiString, Standard_CString ); @@ -825,7 +825,7 @@ Standard_Integer OSD_FileNode::Error () const { } // end OSD_FileNode :: Error -void _osd_wnt_set_error ( OSD_Error& err, OSD_WhoAmI who, ... ) { +void _osd_wnt_set_error ( OSD_Error& err, Standard_Integer who, ... ) { DWORD errCode; diff --git a/src/OSD/OSD_Host.cxx b/src/OSD/OSD_Host.cxx index 38d7414fdd..1547be3fbd 100644 --- a/src/OSD/OSD_Host.cxx +++ b/src/OSD/OSD_Host.cxx @@ -189,7 +189,7 @@ Standard_Integer OSD_Host::Error()const{ #pragma comment( lib, "WSOCK32.LIB" ) #endif -void _osd_wnt_set_error ( OSD_Error&, OSD_WhoAmI, ... ); +void _osd_wnt_set_error ( OSD_Error&, Standard_Integer, ... ); static BOOL fInit = FALSE; static TCollection_AsciiString hostName; @@ -218,11 +218,7 @@ OSD_Host :: OSD_Host () { ZeroMemory (szHostName, sizeof(char) * (MAX_COMPUTERNAME_LENGTH + 1)); // suppress GetVersionEx() deprecation warning -#if defined(__INTEL_COMPILER) - #pragma warning(disable : 1478) -#elif defined(_MSC_VER) - #pragma warning(disable : 4996) -#endif + Standard_DISABLE_DEPRECATION_WARNINGS if (!GetVersionExW (&osVerInfo)) { _osd_wnt_set_error (myError, OSD_WHost); @@ -236,9 +232,7 @@ OSD_Host :: OSD_Host () { ms.dwLength = sizeof(MEMORYSTATUS); GlobalMemoryStatus (&ms); } // end else -#ifdef _MSC_VER - #pragma warning(default : 4996) -#endif + Standard_ENABLE_DEPRECATION_WARNINGS if ( !Failed () ) { diff --git a/src/OSD/OSD_Parallel_TBB.cxx b/src/OSD/OSD_Parallel_TBB.cxx index 9179f8dba4..2344a6ca2d 100644 --- a/src/OSD/OSD_Parallel_TBB.cxx +++ b/src/OSD/OSD_Parallel_TBB.cxx @@ -21,10 +21,12 @@ #include #include +Standard_DISABLE_DEPRECATION_WARNINGS #include #include #include #include +Standard_ENABLE_DEPRECATION_WARNINGS //======================================================================= //function : forEachExternal diff --git a/src/OSD/OSD_Path.cxx b/src/OSD/OSD_Path.cxx index cca6172504..e0b6f9da5e 100644 --- a/src/OSD/OSD_Path.cxx +++ b/src/OSD/OSD_Path.cxx @@ -880,8 +880,9 @@ void OSD_Path::SetExtension(const TCollection_AsciiString& aName){ static void __fastcall _test_raise ( OSD_SysType, Standard_CString ); static void __fastcall _remove_dup ( TCollection_AsciiString& ); -OSD_Path :: OSD_Path () { - +OSD_Path :: OSD_Path () +: myUNCFlag(Standard_False), mySysDep(OSD_WindowsNT) +{ } // end constructor ( 1 ) OSD_Path :: OSD_Path ( diff --git a/src/OSD/OSD_Process.cxx b/src/OSD/OSD_Process.cxx index c3163f4e4d..d7f4b7923e 100644 --- a/src/OSD/OSD_Process.cxx +++ b/src/OSD/OSD_Process.cxx @@ -187,7 +187,7 @@ Standard_Integer OSD_Process::Error()const{ //------------------- WNT Sources of OSD_Path --------------------------- //------------------------------------------------------------------------ -void _osd_wnt_set_error ( OSD_Error&, OSD_WhoAmI, ... ); +void _osd_wnt_set_error ( OSD_Error&, Standard_Integer, ... ); // ======================================================================= // function : OSD_Process diff --git a/src/OSD/OSD_Timer.cxx b/src/OSD/OSD_Timer.cxx index e8bc5d9519..c3129a89be 100644 --- a/src/OSD/OSD_Timer.cxx +++ b/src/OSD/OSD_Timer.cxx @@ -52,10 +52,10 @@ static inline Standard_Real GetWallClockTime () LARGE_INTEGER time; return isOk && QueryPerformanceCounter (&time) ? (Standard_Real)time.QuadPart / (Standard_Real)freq.QuadPart : -#ifndef OCCT_UWP - 0.001 * GetTickCount(); -#else +#if defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0600) 0.001 * GetTickCount64(); +#else + 0.001 * GetTickCount(); #endif } diff --git a/src/QABugs/QABugs_11.cxx b/src/QABugs/QABugs_11.cxx index 983cc5a45f..a3f9ff68dd 100644 --- a/src/QABugs/QABugs_11.cxx +++ b/src/QABugs/QABugs_11.cxx @@ -2207,7 +2207,7 @@ static int StackOverflow (int i = -1) #endif // this code does not work with optimize mode on Windows -#if defined(_MSC_VER) +#if defined(_MSC_VER) && !defined(__clang__) #pragma optimize( "", off ) #endif static Standard_Integer OCC6143 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) @@ -2521,7 +2521,7 @@ static Standard_Integer OCC30775 (Draw_Interpretor& theDI, Standard_Integer theN return 0; } -#if defined(_MSC_VER) +#if defined(_MSC_VER) && !defined(__clang__) #pragma optimize( "", on ) #endif diff --git a/src/QABugs/QABugs_19.cxx b/src/QABugs/QABugs_19.cxx index dfce9c34fe..9299de9807 100644 --- a/src/QABugs/QABugs_19.cxx +++ b/src/QABugs/QABugs_19.cxx @@ -57,9 +57,11 @@ #include #ifdef HAVE_TBB + Standard_DISABLE_DEPRECATION_WARNINGS #include #include #include + Standard_ENABLE_DEPRECATION_WARNINGS #endif #include diff --git a/src/Quantity/Quantity_ColorRGBA.cxx b/src/Quantity/Quantity_ColorRGBA.cxx index 3db480fa39..ca1745313b 100644 --- a/src/Quantity/Quantity_ColorRGBA.cxx +++ b/src/Quantity/Quantity_ColorRGBA.cxx @@ -44,7 +44,7 @@ namespace const ColorInteger theColorComponentBase) { Standard_ASSERT_RETURN (theColorComponentBase >= 2, - __FUNCTION__ ": 'theColorComponentBase' must be greater than 1.", + "'theColorComponentBase' must be greater than 1.", 0.0f); const ColorInteger aColorComponentMaxValue = theColorComponentBase - 1; const ColorInteger aColorComponentAsInteger = theColorInteger % theColorComponentBase; @@ -67,7 +67,7 @@ namespace Quantity_ColorRGBA& theColor) { Standard_ASSERT_RETURN (theColorComponentBase >= 2, - __FUNCTION__ ": 'theColorComponentBase' must be greater than 1.", + "'theColorComponentBase' must be greater than 1.", 0.0f); Graphic3d_Vec4 aColor (1.0f); if (hasAlphaComponent) diff --git a/src/Standard/Standard_ErrorHandler.hxx b/src/Standard/Standard_ErrorHandler.hxx index 5071021411..09bdc7bfbf 100644 --- a/src/Standard/Standard_ErrorHandler.hxx +++ b/src/Standard/Standard_ErrorHandler.hxx @@ -202,6 +202,8 @@ inline Standard_ErrorHandler::Callback::Callback () } inline Standard_ErrorHandler::Callback::~Callback () { + (void)myHandler; + (void)myPrev; } inline void Standard_ErrorHandler::Callback::RegisterCallback () { diff --git a/src/Standard/Standard_Macro.hxx b/src/Standard/Standard_Macro.hxx index a2ab9188a4..63303b2de1 100644 --- a/src/Standard/Standard_Macro.hxx +++ b/src/Standard/Standard_Macro.hxx @@ -147,14 +147,14 @@ #if defined(__ICL) || defined (__INTEL_COMPILER) #define Standard_DISABLE_DEPRECATION_WARNINGS __pragma(warning(push)) __pragma(warning(disable:1478)) #define Standard_ENABLE_DEPRECATION_WARNINGS __pragma(warning(pop)) -#elif defined(_MSC_VER) - #define Standard_DISABLE_DEPRECATION_WARNINGS __pragma(warning(push)) __pragma(warning(disable:4996)) - #define Standard_ENABLE_DEPRECATION_WARNINGS __pragma(warning(pop)) #elif (defined(__GNUC__) && __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) || defined(__clang__) // available since at least gcc 4.2 (maybe earlier), however only gcc 4.6+ supports this pragma inside the function body // CLang also supports this gcc syntax (in addition to "clang diagnostic ignored") #define Standard_DISABLE_DEPRECATION_WARNINGS _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") #define Standard_ENABLE_DEPRECATION_WARNINGS _Pragma("GCC diagnostic warning \"-Wdeprecated-declarations\"") +#elif defined(_MSC_VER) + #define Standard_DISABLE_DEPRECATION_WARNINGS __pragma(warning(push)) __pragma(warning(disable:4996)) + #define Standard_ENABLE_DEPRECATION_WARNINGS __pragma(warning(pop)) #else #define Standard_DISABLE_DEPRECATION_WARNINGS #define Standard_ENABLE_DEPRECATION_WARNINGS diff --git a/src/StepFile/lex.step.c b/src/StepFile/lex.step.c index 66baa717ce..88f946e0bf 100644 --- a/src/StepFile/lex.step.c +++ b/src/StepFile/lex.step.c @@ -552,6 +552,10 @@ void rec_typarg(int argtype); // Note that Intel compiler also defines _MSC_VER but has different warning ids #if defined(__INTEL_COMPILER) #pragma warning(disable:177 1786 1736) +#elif defined(__clang__) +#pragma GCC diagnostic ignored "-Wunused-function" +#pragma GCC diagnostic ignored "-Winconsistent-dllimport" +#pragma GCC diagnostic ignored "-Wunneeded-internal-declaration" #else #pragma warning(disable:4131 4244 4273 4267 4127) #endif diff --git a/src/StepFile/step.lex b/src/StepFile/step.lex index 94179ea56b..dd3340da5e 100644 --- a/src/StepFile/step.lex +++ b/src/StepFile/step.lex @@ -47,6 +47,11 @@ void rec_typarg(int argtype); // Note that Intel compiler also defines _MSC_VER but has different warning ids #if defined(__INTEL_COMPILER) #pragma warning(disable:177 1786 1736) +#elif defined(__clang__) +#pragma GCC diagnostic ignored "-Wunused-function" +#pragma GCC diagnostic ignored "-Winconsistent-dllimport" +#pragma GCC diagnostic ignored "-Wunneeded-internal-declaration" +#else #else #pragma warning(disable:4131 4244 4273 4267 4127) #endif diff --git a/src/Storage/Storage_Schema.cxx b/src/Storage/Storage_Schema.cxx index e070d8d5ee..7968ffdbfd 100644 --- a/src/Storage/Storage_Schema.cxx +++ b/src/Storage/Storage_Schema.cxx @@ -205,6 +205,9 @@ void Storage_BucketOfPersistent::Append(const Handle(Standard_Persistent)& sp) Storage_BucketIterator::Storage_BucketIterator (Storage_BucketOfPersistent* aBucketManager) +: myBucket(0), myCurrentBucket(0), + myCurrentBucketIndex(0), myCurrentIndex(0), + myBucketNumber(0), myMoreObject(Standard_False) { if (aBucketManager) { myBucket = aBucketManager; @@ -214,7 +217,6 @@ Storage_BucketIterator::Storage_BucketIterator myCurrentIndex = 0; myMoreObject = Standard_True; } - else myMoreObject = Standard_False; } //======================================================================= diff --git a/src/ViewerTest/ViewerTest.hxx b/src/ViewerTest/ViewerTest.hxx index b9665cfc7d..0d1301b551 100644 --- a/src/ViewerTest/ViewerTest.hxx +++ b/src/ViewerTest/ViewerTest.hxx @@ -34,6 +34,7 @@ class V3d_View; class V3d_Viewer; class ViewerTest_EventManager; class TopoDS_Shape; +class WNT_WClass; class ViewerTest { @@ -257,7 +258,7 @@ private: //! Ctrl+MB2 for pan, etc) and keyboard shortcuts. //! This method is relevant for MS Windows only and respectively //! returns WNT_WClass handle. - static const Handle(Standard_Transient)& WClass(); + static const Handle(WNT_WClass)& WClass(); }; #endif // _ViewerTest_HeaderFile diff --git a/src/ViewerTest/ViewerTest_CmdParser.cxx b/src/ViewerTest/ViewerTest_CmdParser.cxx index fbdb9c243f..bbffa5dd6d 100644 --- a/src/ViewerTest/ViewerTest_CmdParser.cxx +++ b/src/ViewerTest/ViewerTest_CmdParser.cxx @@ -305,7 +305,7 @@ bool ViewerTest_CmdParser::Arg (const std::string& theOptionName, std::string& theOptionArgument) const { Standard_ASSERT_RETURN (theArgumentIndex >= 0, - __FUNCTION__ ": 'theArgumentIndex' must be greater than or equal to zero.", + "'theArgumentIndex' must be greater than or equal to zero.", false); ViewerTest_CommandOptionKey anOptionKey = THE_UNNAMED_COMMAND_OPTION_KEY; if (!theOptionName.empty() && !findOptionKey (theOptionName, anOptionKey)) @@ -324,7 +324,7 @@ bool ViewerTest_CmdParser::Arg (const ViewerTest_CommandOptionKey theOptionKey, std::string& theOptionArgument) const { Standard_ASSERT_RETURN (theArgumentIndex >= 0, - __FUNCTION__ ": 'theArgumentIndex' must be greater than or equal to zero.", + "'theArgumentIndex' must be greater than or equal to zero.", false); std::size_t aUsedOptionIndex = 0; if (!findUsedOptionIndex (theOptionKey, aUsedOptionIndex)) @@ -347,7 +347,7 @@ bool ViewerTest_CmdParser::Arg (const ViewerTest_CommandOptionKey theOptionKey, std::string ViewerTest_CmdParser::Arg (const std::string& theOptionName, const Standard_Integer theArgumentIndex) const { Standard_ASSERT_RETURN (theArgumentIndex >= 0, - __FUNCTION__ ": 'theArgumentIndex' must be greater than or equal to zero.", + "'theArgumentIndex' must be greater than or equal to zero.", std::string()); std::string anOptionArgument; if (!Arg (theOptionName, theArgumentIndex, anOptionArgument)) @@ -501,8 +501,8 @@ bool ViewerTest_CmdParser::ArgColor (const ViewerTest_CommandOptionKey theOption const RawStringArguments aRawStringArguments = getRawStringArguments (aUsedOptionIndex); const Standard_Integer aNumberOfArguments = static_cast (aRawStringArguments.size()); Standard_ASSERT_RETURN (theArgumentIndex < aNumberOfArguments, - __FUNCTION__ ": 'theArgumentIndex' must be less than the number of command-line arguments " - "passed with the option which access key is 'theOptionKey'.", + "'theArgumentIndex' must be less than the number of command-line arguments " + "passed with the option which access key is 'theOptionKey'.", false); const Standard_Integer aNumberOfAvailableArguments = aNumberOfArguments - theArgumentIndex; TheColor aColor; @@ -601,7 +601,7 @@ ViewerTest_CmdParser::RawStringArguments ViewerTest_CmdParser::getRawStringArgum { Standard_ASSERT_RETURN ( theUsedOptionIndex < myOptionArgumentStorage.size(), - __FUNCTION__ ": 'theUsedOptionIndex' must be less than the size of 'myOptionArgumentStorage'.", + "'theUsedOptionIndex' must be less than the size of 'myOptionArgumentStorage'.", RawStringArguments()); const OptionArguments& anOptionArguments = myOptionArgumentStorage[theUsedOptionIndex]; return convertToRawStringList (anOptionArguments); diff --git a/src/ViewerTest/ViewerTest_ViewerCommands.cxx b/src/ViewerTest/ViewerTest_ViewerCommands.cxx index 336ecbd331..6790f6dba6 100644 --- a/src/ViewerTest/ViewerTest_ViewerCommands.cxx +++ b/src/ViewerTest/ViewerTest_ViewerCommands.cxx @@ -1367,13 +1367,13 @@ static LRESULT WINAPI AdvViewerWindowProc( //purpose : //============================================================================== -const Handle(Standard_Transient)& ViewerTest::WClass() +const Handle(WNT_WClass)& ViewerTest::WClass() { - static Handle(Standard_Transient) theWClass; + static Handle(WNT_WClass) theWClass; #if defined(_WIN32) if (theWClass.IsNull()) { - theWClass = new WNT_WClass ("GW3D_Class", (Standard_Address )AdvViewerWindowProc, + theWClass = new WNT_WClass ("GW3D_Class", AdvViewerWindowProc, CS_VREDRAW | CS_HREDRAW, 0, 0, ::LoadCursor (NULL, IDC_ARROW)); } @@ -1909,8 +1909,7 @@ TCollection_AsciiString ViewerTest::ViewerInit (const Standard_Integer thePxLeft // Create window #if defined(_WIN32) - VT_GetWindow() = new WNT_Window (aTitle.ToCString(), - Handle(WNT_WClass)::DownCast (WClass()), + VT_GetWindow() = new WNT_Window (aTitle.ToCString(), WClass(), Draw_VirtualWindows ? WS_POPUP : WS_OVERLAPPEDWINDOW, aPxLeft, aPxTop, aPxWidth, aPxHeight, -- 2.39.5