Warnings issued by gcc 8.1.0 are eliminated.
New Standard_WarningDisableFunctionCast.hxx header file is introduced to disable GCC warning "-Wcast-function-type" in those files *.cxx where it is issued. This warning is issued when the conversion from the pointer to one function type to the pointer to another function type takes places, it was added in gcc 8.1.0.
The function MyVISEDG in SWDRAW_ShapeAnalysis.cxx is removed as it does not seem to do anything useful and relevant DRAW command K_VISEDG is never used in tests.
}
BiTgte_ContactType Type = BiTgte_VertexVertex;
- switch (Type1) {
-
- case TopAbs_VERTEX:
- switch (Type2) {
- case TopAbs_VERTEX: Type = BiTgte_VertexVertex; break;
- case TopAbs_EDGE: Type = BiTgte_EdgeVertex; break;
- case TopAbs_FACE: Type = BiTgte_FaceVertex; break;
- default:
+ switch (Type1)
+ {
+ case TopAbs_VERTEX:
+ switch (Type2)
+ {
+ case TopAbs_VERTEX: Type = BiTgte_VertexVertex; break;
+ case TopAbs_EDGE: Type = BiTgte_EdgeVertex; break;
+ case TopAbs_FACE: Type = BiTgte_FaceVertex; break;
+ default:
+ break;
+ }
break;
- }
-
- case TopAbs_EDGE:
- switch (Type2) {
- case TopAbs_EDGE: Type = BiTgte_EdgeEdge; break;
- case TopAbs_FACE: Type = BiTgte_FaceEdge; break;
- default:
+
+ case TopAbs_EDGE:
+ switch (Type2)
+ {
+ case TopAbs_EDGE: Type = BiTgte_EdgeEdge; break;
+ case TopAbs_FACE: Type = BiTgte_FaceEdge; break;
+ default:
+ break;
+ }
break;
- }
-
- case TopAbs_FACE:
- switch (Type2) {
- case TopAbs_FACE: Type = BiTgte_FaceEdge; break;
+
+ case TopAbs_FACE:
+ switch (Type2)
+ {
+ case TopAbs_FACE: Type = BiTgte_FaceEdge; break;
+ default:
+ break;
+ }
+ break;
+
default:
break;
- }
- default:
- break;
}
-
+
return Type;
}
#include <D3DHost_GraphicDriver.hxx>
#include <TCollection_ExtendedString.hxx>
+#include <Standard_WarningDisableFunctionCast.hxx>
+
IMPLEMENT_STANDARD_RTTIEXT(D3DHost_View,OpenGl_View)
// =======================================================================
#include <TCollection_AsciiString.hxx>
#include <tcl.h>
+
+#include <Standard_WarningDisableFunctionCast.hxx>
+
// on MSVC, use #pragma to define name of the Tcl library to link with,
// depending on Tcl version number
#ifdef _MSC_VER
y2=a4;
}
-static DWORD WINAPI tkLoop(VOID);
+static DWORD WINAPI tkLoop (LPVOID theThreadParameter);
#ifdef _TK
static Tk_Window mainWindow;
#endif
dwMainThreadId = GetCurrentThreadId();
//necessary for normal Tk operation
- hThread = CreateThread(NULL, // no security attributes
- 0, // use default stack size
- (LPTHREAD_START_ROUTINE) tkLoop, // thread function
- NULL, // no thread function argument
- 0, // use default creation flags
- &IDThread);
+ hThread = CreateThread (NULL, // no security attributes
+ 0, // use default stack size
+ tkLoop, // thread function
+ NULL, // no thread function argument
+ 0, // use default creation flags
+ &IDThread);
if (!hThread) {
std::cout << "Failed to create Tcl/Tk main loop thread. Switching to batch mode..." << std::endl;
Draw_Batch = Standard_True;
/*--------------------------------------------------------*\
| readStdinThreadFunc
\*--------------------------------------------------------*/
-static DWORD WINAPI readStdinThreadFunc()
+static DWORD WINAPI readStdinThreadFunc (const LPVOID theThreadParameter)
{
+ (void)theThreadParameter;
if (!Draw_IsConsoleSubsystem)
{
return 1;
/*--------------------------------------------------------*\
| tkLoop: implements Tk_Main()-like behaviour in a separate thread
\*--------------------------------------------------------*/
-static DWORD WINAPI tkLoop(VOID)
+static DWORD WINAPI tkLoop (const LPVOID theThreadParameter)
{
+ (void)theThreadParameter;
Tcl_CreateExitHandler(exitProc, 0);
Draw_Interpretor& aCommands = Draw::GetInterpretor();
#endif
}
}
- catch (Standard_Failure)
+ catch (const Standard_Failure&)
{
std::cout << "tkLoop: exception in TK_Init\n";
}
DWORD IDThread;
HANDLE hThread;
if (Draw_IsConsoleSubsystem) {
- hThread = CreateThread(NULL, // no security attributes
- 0, // use default stack size
- (LPTHREAD_START_ROUTINE) readStdinThreadFunc, // thread function
- NULL, // no thread function argument
- 0, // use default creation flags
- &IDThread); // returns thread identifier
+ hThread = CreateThread (NULL, // no security attributes
+ 0, // use default stack size
+ readStdinThreadFunc, // thread function
+ NULL, // no thread function argument
+ 0, // use default creation flags
+ &IDThread); // returns thread identifier
if (!hThread) {
std::cout << "pb in creation of the thread reading stdin" << std::endl;
Draw_IsConsoleSubsystem = Standard_False;
{
// Reverse the bytes throughout the buffer
const Standard_ExtCharacter* const anEnd =
- reinterpret_cast<const Standard_ExtCharacter* const>(&anMsgBuffer[aFileSize]);
+ reinterpret_cast<const Standard_ExtCharacter*>(&anMsgBuffer[aFileSize]);
for (Standard_ExtCharacter* aPtr = aUnicodeBuffer; aPtr < anEnd; aPtr++)
{
#endif
#endif
+#include <Standard_WarningDisableFunctionCast.hxx>
+
namespace {
#if defined(_WIN32) && !defined(OCCT_UWP)
#include <TCollection_AsciiString.hxx>
#include <TCollection_ExtendedString.hxx>
+#include <Standard_WarningDisableFunctionCast.hxx>
+
static DWORD lastDLLError;
static wchar_t errMsg[1024];
if (retVal || (!retVal && GetLastError() == ERROR_ALREADY_EXISTS))
{
size_t anOldDirLength;
- StringCchLengthW (oldDir, sizeof(oldDir) / sizeof(oldDir[0]), &anOldDirLength);
+ StringCchLengthW (oldDir, MAX_PATH, &anOldDirLength);
+ const size_t aNameLength = anOldDirLength + WILD_CARD_LEN + sizeof (L'\x00');
if ((pFD = (WIN32_FIND_DATAW* )HeapAlloc (hHeap, 0, sizeof(WIN32_FIND_DATAW))) != NULL
- && (pName = (wchar_t* )HeapAlloc (hHeap, 0, anOldDirLength + WILD_CARD_LEN + sizeof(L'\x00'))) != NULL)
+ && (pName = (wchar_t* )HeapAlloc (hHeap, 0, aNameLength)) != NULL)
{
- StringCchCopyW (pName, sizeof(pName) / sizeof(pName[0]), oldDir);
- StringCchCatW (pName, sizeof(pName), WILD_CARD);
+ StringCchCopyW (pName, aNameLength, oldDir);
+ StringCchCatW (pName, aNameLength, WILD_CARD);
retVal = TRUE;
hFindFile = FindFirstFileExW (pName, FindExInfoStandard, pFD, FindExSearchNameMatch, NULL, 0);
for (BOOL fFind = hFindFile != INVALID_HANDLE_VALUE; fFind; fFind = FindNextFileW (hFindFile, pFD))
continue;
}
- size_t anOldDirLength2 = 0, aNewDirLength = 0, aFileNameLength = 0;
- StringCchLengthW (oldDir, sizeof(oldDir) / sizeof(oldDir[0]), &anOldDirLength2);
- StringCchLengthW (newDir, sizeof(newDir) / sizeof(newDir[0]), &aNewDirLength);
+ size_t aNewDirLength = 0, aFileNameLength = 0;
+ StringCchLengthW (newDir, MAX_PATH, &aNewDirLength);
StringCchLengthW (pFD->cFileName, sizeof(pFD->cFileName) / sizeof(pFD->cFileName[0]), &aFileNameLength);
- if ((pFullNameSrc = (wchar_t* )HeapAlloc (hHeap, 0, anOldDirLength2 + aFileNameLength + sizeof(L'/') + sizeof(L'\x00'))) == NULL
- || (pFullNameDst = (wchar_t* )HeapAlloc (hHeap, 0, aNewDirLength + aFileNameLength + sizeof(L'/') + sizeof(L'\x00'))) == NULL)
+ const size_t aFullNameSrcLength = anOldDirLength + aFileNameLength + sizeof (L'/') + sizeof (L'\x00');
+ const size_t aFullNameDstLength = aNewDirLength + aFileNameLength + sizeof (L'/') + sizeof (L'\x00');
+ if ((pFullNameSrc = (wchar_t* )HeapAlloc (hHeap, 0, aFullNameSrcLength)) == NULL
+ || (pFullNameDst = (wchar_t* )HeapAlloc (hHeap, 0, aFullNameDstLength)) == NULL)
{
break;
}
- StringCchCopyW (pFullNameSrc, sizeof(pFullNameSrc) / sizeof(pFullNameSrc[0]), oldDir);
- StringCchCatW (pFullNameSrc, sizeof(pFullNameSrc) / sizeof(pFullNameSrc[0]), L"/");
- StringCchCatW (pFullNameSrc, sizeof(pFullNameSrc) / sizeof(pFullNameSrc[0]), pFD->cFileName);
+ StringCchCopyW (pFullNameSrc, aFullNameSrcLength, oldDir);
+ StringCchCatW (pFullNameSrc, aFullNameSrcLength, L"/");
+ StringCchCatW (pFullNameSrc, aFullNameSrcLength, pFD->cFileName);
- StringCchCopyW (pFullNameDst, sizeof(pFullNameDst) / sizeof(pFullNameDst[0]), newDir);
- StringCchCatW (pFullNameDst, sizeof(pFullNameDst) / sizeof(pFullNameDst[0]), L"/");
- StringCchCatW (pFullNameDst, sizeof(pFullNameDst) / sizeof(pFullNameDst[0]), pFD->cFileName);
+ StringCchCopyW (pFullNameDst, aFullNameDstLength, newDir);
+ StringCchCatW (pFullNameDst, aFullNameDstLength, L"/");
+ StringCchCatW (pFullNameDst, aFullNameDstLength, pFD->cFileName);
if ((pFD->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0)
{
if (retVal || (!retVal && GetLastError() == ERROR_ALREADY_EXISTS))
{
size_t aDirSrcLength = 0;
- StringCchLengthW (dirSrc, sizeof(dirSrc) / sizeof(dirSrc[0]), &aDirSrcLength);
+ StringCchLengthW (dirSrc, MAX_PATH, &aDirSrcLength);
+ const size_t aNameLength = aDirSrcLength + WILD_CARD_LEN + sizeof (L'\x00');
if ((pFD = (WIN32_FIND_DATAW* )HeapAlloc (hHeap, 0, sizeof(WIN32_FIND_DATAW))) != NULL
- && (pName = (wchar_t* )HeapAlloc (hHeap, 0, aDirSrcLength + WILD_CARD_LEN + sizeof(L'\x00'))) != NULL)
+ && (pName = (wchar_t* )HeapAlloc (hHeap, 0, aNameLength)) != NULL)
{
- StringCchCopyW(pName, sizeof(pName) / sizeof(pName[0]), dirSrc);
- StringCchCatW (pName, sizeof(pName) / sizeof(pName[0]), WILD_CARD);
+ StringCchCopyW(pName, aNameLength, dirSrc);
+ StringCchCatW (pName, aNameLength, WILD_CARD);
retVal = TRUE;
hFindFile = FindFirstFileExW (pName, FindExInfoStandard, pFD, FindExSearchNameMatch, NULL, 0);
continue;
}
- size_t aDirSrcLength2 = 0, aDirDstLength = 0, aFileNameLength = 0;
- StringCchLengthW (dirSrc, sizeof(dirSrc) / sizeof(dirSrc[0]), &aDirSrcLength2);
- StringCchLengthW (dirDst, sizeof(dirDst) / sizeof(dirDst[0]), &aDirDstLength);
+ size_t aDirDstLength = 0, aFileNameLength = 0;
+ StringCchLengthW (dirDst, MAX_PATH, &aDirDstLength);
StringCchLengthW (pFD->cFileName, sizeof(pFD->cFileName) / sizeof(pFD->cFileName[0]), &aFileNameLength);
- if ((pFullNameSrc = (wchar_t* )HeapAlloc (hHeap, 0, aDirSrcLength2 + aFileNameLength + sizeof(L'/') + sizeof(L'\x00'))) == NULL
- || (pFullNameDst = (wchar_t* )HeapAlloc (hHeap, 0, aDirDstLength + aFileNameLength + sizeof(L'/') + sizeof(L'\x00'))) == NULL)
+ const size_t aFullNameSrcLength = aDirSrcLength + aFileNameLength + sizeof (L'/') + sizeof (L'\x00');
+ const size_t aFullNameDstLength = aDirDstLength + aFileNameLength + sizeof (L'/') + sizeof (L'\x00');
+ if ((pFullNameSrc = (wchar_t* )HeapAlloc (hHeap, 0, aFullNameSrcLength)) == NULL
+ || (pFullNameDst = (wchar_t* )HeapAlloc (hHeap, 0, aFullNameDstLength)) == NULL)
{
break;
}
- StringCchCopyW (pFullNameSrc, sizeof(pFullNameSrc) / sizeof(pFullNameSrc[0]), dirSrc);
- StringCchCatW (pFullNameSrc, sizeof(pFullNameSrc) / sizeof(pFullNameSrc[0]), L"/");
- StringCchCatW (pFullNameSrc, sizeof(pFullNameSrc) / sizeof(pFullNameSrc[0]), pFD->cFileName);
+ StringCchCopyW (pFullNameSrc, aFullNameSrcLength, dirSrc);
+ StringCchCatW (pFullNameSrc, aFullNameSrcLength, L"/");
+ StringCchCatW (pFullNameSrc, aFullNameSrcLength, pFD->cFileName);
- StringCchCopyW (pFullNameDst, sizeof(pFullNameDst) / sizeof(pFullNameDst[0]), dirDst);
- StringCchCatW (pFullNameDst, sizeof(pFullNameDst) / sizeof(pFullNameDst[0]), L"/");
- StringCchCatW (pFullNameDst, sizeof(pFullNameDst) / sizeof(pFullNameDst[0]), pFD->cFileName);
+ StringCchCopyW (pFullNameDst, aFullNameDstLength, dirDst);
+ StringCchCatW (pFullNameDst, aFullNameDstLength, L"/");
+ StringCchCatW (pFullNameDst, aFullNameDstLength, pFD->cFileName);
if ((pFD->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0)
{
retVal = CopyDirectory (pFullNameSrc, pFullNameDst);
#include <Standard_Overflow.hxx>
#include <Standard_Assert.hxx>
+#include <Standard_WarningDisableFunctionCast.hxx>
+
static OSD_SignalMode OSD_WasSetSignal = OSD_SignalMode_AsIs;
//=======================================================================
#include <memory>
+#include <Standard_WarningDisableFunctionCast.hxx>
+
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_Window,Standard_Transient)
#if defined(HAVE_EGL)
#include <Standard_Transient.hxx>
#include <TCollection_AsciiString.hxx>
+#include <Standard_WarningDisableFunctionCast.hxx>
+
static Standard_Character tc[1000];
static Standard_PCharacter thePluginId = tc;
it.Initialize (empty);
}
- catch (Standard_Failure)
+ catch (const Standard_Failure&)
{
di << "Cannot initialize TopoDS_Iterator with null shape\n";
return 0;
TopoDS_Wire empty;
BRepLib_MakeWire aWBuilder (empty);
}
- catch (Standard_Failure)
+ catch (const Standard_Failure&)
{
di << "Cannot initialize BRepLib_MakeWire with null wire\n";
}
}
-//=======================================================================
-//function : MyVISEDG
-//purpose :
-//=======================================================================
-static Standard_Integer MyVISEDG (Draw_Interpretor& /*di*/,
- Standard_Integer n, const char** a)
-{
- if (n >4) return 1;
- TopoDS_Shape MaListe = DBRep::Get(a[1]);
- if (MaListe.IsNull()) return 1;
- TopoDS_Compound TheList = TopoDS::Compound(MaListe);
- if (TheList.IsNull()) return 1;
- Standard_Real toler = 0.001;
- int create = 0;
- if ( n >= 3) toler = Draw::Atof(a[2]);
- if (n == 4 && !strcmp(a[3],"C")) create = 1;
- ShapeAnalysis_FreeBounds F(TheList,toler);
- //
- //
- //
- char name[100];
- char num[5];
- if (!create)
- {
- TopoDS_Compound Wires = F.GetClosedWires();
- TopoDS_Iterator S(Wires);
- Standard_Integer iwire = 0;
- while (S.More())
- {
- Sprintf (num,"%d",iwire);
- name[0] = 'w';
- name[1] = '\0';
- strncat(name,num,strlen(num));
- name[strlen(name)] = '\0';
- DBRep::Set(name,S.Value());
- S.Next();
- iwire++;
- }
- iwire = 0;
- TopoDS_Compound Edges = F.GetOpenWires();
- S.Initialize(Edges);
- iwire = 0;
- while (S.More())
- {
- Sprintf (num,"%d",iwire);
- name[0] = 'E';
- name[1] = '\0';
- strncat(name,num,strlen(num));
- name[strlen(name)] = '\0';
- DBRep::Set(name,S.Value());
- S.Next();
- iwire++;
- }
- }
- else
- {
- }
- return 0;
-}
-
static Standard_Integer getareacontour (Draw_Interpretor& di,
Standard_Integer n, const char** a)
{
theCommands.Add("fbclose",
"shp sewtoler closetoler [splitclosed [splitopen]] - closes free bounds; use sewtoler <= 0 for shells (no sewing call)",
__FILE__, closefreebounds, groupold);
- theCommands.Add("K_VISEDG",
- "K_VISEDG Visu of free edge of a compound of faces.",
- __FILE__, MyVISEDG, groupold);
theCommands.Add("getareacontour","wire ",__FILE__, getareacontour, groupold);
theCommands.Add ("checkselfintersection","wire [face]", __FILE__,checkselfintersection,g);
Standard_ExtString.hxx
Standard_Failure.cxx
Standard_Failure.hxx
+Standard_WarningDisableFunctionCast.hxx
Standard_GUID.cxx
Standard_GUID.hxx
Standard_Handle.hxx
--- /dev/null
+// Copyright (c) 2019 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _Standard_WarningDisableFunctionCast_HeaderFile
+#define _Standard_WarningDisableFunctionCast_HeaderFile
+
+//! @file
+//! Include this file to disable GCC warning -Wcast-function-type introduced in GCC 8.1.
+//!
+//! This diagnostic warns when a function pointer is cast to an incompatible function pointer.
+//! Existing APIs loading function pointer from library (like dlsym() or wglGetProcAddress()) have no
+//! possibility to return function of specified type nor to verify that exported symbol actually
+//! matches the expected function signature, so that unsafe function cast is unavoidable.
+//! There is no way to prevent this warning at OCCT level (until safer APIs is introduced), thus
+//! suppressing it is the only feasible way to avoid it. As this warning still can point out broken
+//! places, it should be suppressed only locally, where usage of function cast has been verified.
+#if defined(__GNUC__) && !defined(__INTEL_COMPILER) && !defined(__clang__)
+# if (__GNUC__ > 8) || ((__GNUC__ == 8) && (__GNUC_MINOR__ >= 1))
+# pragma GCC diagnostic ignored "-Wcast-function-type"
+# endif
+#endif
+
+#endif // _Standard_WarningDisableFunctionCast_HeaderFile