1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

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 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
This commit is contained in:
abv
2019-10-11 22:04:02 +03:00
parent 6466cc9eb1
commit 1bd04b5a02
41 changed files with 134 additions and 100 deletions

View File

@@ -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

View File

@@ -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<Standard_Integer> (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);

View File

@@ -1397,9 +1397,9 @@ 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())
{
@@ -1939,8 +1939,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,