]> OCCT Git - occt-copy.git/commitdiff
0030609: Coding - eliminate warnings issued by gcc 8.1.0
authortiv <tiv@opencascade.com>
Wed, 16 Oct 2019 17:47:30 +0000 (20:47 +0300)
committerabv <abv@opencascade.com>
Sat, 19 Oct 2019 09:31:41 +0000 (12:31 +0300)
Warnings issued by gcc 8.1.0 are eliminated.
New function OSD_FunctionCast() is introduced to explicitly mark places where the conversion from the pointer to one function type to the pointer to another function type takes place and to suppress gcc warning "-Wcast-function-type" (introduced in gcc 8.1.0).

14 files changed:
src/BiTgte/BiTgte_Blend.cxx
src/D3DHost/D3DHost_View.cxx
src/Draw/Draw.cxx
src/Draw/Draw_Window.cxx
src/Message/Message_MsgFile.cxx
src/OSD/OSD_Function.hxx
src/OSD/OSD_Parallel.cxx
src/OSD/OSD_SharedLibrary.cxx
src/OSD/OSD_WNT.cxx
src/OSD/OSD_signal.cxx
src/OpenGl/OpenGl_Window.cxx
src/Plugin/Plugin.cxx
src/QABugs/QABugs_20.cxx
src/SWDRAW/SWDRAW_ShapeAnalysis.cxx

index 6bbb10245b436d015b95ba0329c9accfe71210e9..77c0ae4b47e4fc8b38b8dda7392b17c259682ffe 100644 (file)
@@ -1192,35 +1192,42 @@ BiTgte_ContactType BiTgte_Blend::ContactType(const Standard_Integer Index)
   }
   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;
 }
 
index 6b9f76baea3431e00d6ab37c7f8aec040086c65e..df3846de5e2a7d5edac02cfbe711161132847f5b 100644 (file)
@@ -19,6 +19,7 @@
 
 #include <D3DHost_GraphicDriver.hxx>
 #include <TCollection_ExtendedString.hxx>
+#include <OSD_Function.hxx>
 
 IMPLEMENT_STANDARD_RTTIEXT(D3DHost_View,OpenGl_View)
 
@@ -143,7 +144,7 @@ bool D3DHost_View::d3dInitLib()
     {
       // retrieve D3D9Ex function dynamically (available only since Vista+)
       typedef HRESULT (WINAPI* Direct3DCreate9Ex_t)(UINT , IDirect3D9Ex** );
-      Direct3DCreate9Ex_t Direct3DCreate9ExProc = (Direct3DCreate9Ex_t )GetProcAddress (aLib, "Direct3DCreate9Ex");
+      Direct3DCreate9Ex_t Direct3DCreate9ExProc = OSD_FunctionCast<Direct3DCreate9Ex_t> (GetProcAddress (aLib, "Direct3DCreate9Ex"));
       if (Direct3DCreate9ExProc != NULL)
       {
         Direct3DCreate9ExProc(D3D_SDK_VERSION, &aD3dLibEx);
index f0a27e42da3d8c3056402964b15662e26c4ac199..0812529ca703bb29688a17856dd7b4a1f08b0dbc 100644 (file)
@@ -278,7 +278,7 @@ void Draw_Appli(int argc, char** argv, const FDraw_InitAppli Draw_InitAppli)
     typedef BOOL (WINAPI *SetDllDirectoryW_t)(const wchar_t* thePathName);
     HMODULE aKern32Module = GetModuleHandleW (L"kernel32");
     SetDllDirectoryW_t aFunc = (aKern32Module != NULL)
-                             ? (SetDllDirectoryW_t )GetProcAddress (aKern32Module, "SetDllDirectoryW") : NULL;
+                             ? OSD_FunctionCast<SetDllDirectoryW_t> (GetProcAddress (aKern32Module, "SetDllDirectoryW")) : NULL;
     if (aFunc != NULL)
     {
       aFunc (aUserDllPath.ToWideString());
@@ -724,8 +724,7 @@ void Draw::Load(Draw_Interpretor& theDI, const TCollection_AsciiString& theKey,
 //   fp = (void (*)(Draw_Interpretor&, const TCollection_AsciiString&)) f;
 //   (*fp) (theDI, theKey);
 
-  void (*fp) (Draw_Interpretor&) = NULL;
-  fp = (void (*)(Draw_Interpretor&)) f;
+  void (*fp) (Draw_Interpretor&) = OSD_FunctionCast<void (*) (Draw_Interpretor&)> (f);
   (*fp) (theDI);
 
 }
index 4602f31b573c8b22f81fdf5e99b188b99fd637cf..f096767e677dda1ea3d1e729a1d460cfe88f05b5 100644 (file)
@@ -2003,7 +2003,7 @@ void Segment::Init(Standard_Integer a1, Standard_Integer a2,
   y2=a4;
 }
 
-static DWORD WINAPI tkLoop(VOID);
+static DWORD WINAPI tkLoop (LPVOID theThreadParameter);
 #ifdef _TK
 static Tk_Window mainWindow;
 #endif
@@ -2027,12 +2027,12 @@ Standard_Boolean Init_Appli(HINSTANCE hInst,
   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;
@@ -2082,8 +2082,9 @@ Standard_Boolean Draw_Interprete (const char*);
 /*--------------------------------------------------------*\
 |  readStdinThreadFunc
 \*--------------------------------------------------------*/
-static DWORD WINAPI readStdinThreadFunc()
+static DWORD WINAPI readStdinThreadFunc (const LPVOID theThreadParameter)
 {
+  (void)theThreadParameter;
   if (!Draw_IsConsoleSubsystem)
   {
     return 1;
@@ -2246,8 +2247,9 @@ static void ResetStdChannel (int type)
 /*--------------------------------------------------------*\
 |  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();
@@ -2309,7 +2311,7 @@ static DWORD WINAPI tkLoop(VOID)
 #endif
       }
     }
-    catch (Standard_Failure)
+    catch (const Standard_Failure&)
     {
       std::cout << "tkLoop: exception in TK_Init\n";
     }
@@ -2389,12 +2391,12 @@ void Run_Appli(HWND hWnd)
   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;
index 2c5deba4f402914fac0be245fe3346f547e38862..22ffbbc56f2f3c522cfe90c84afb0569074e1e3b 100644 (file)
@@ -257,7 +257,7 @@ Standard_Boolean Message_MsgFile::LoadFile (const Standard_CString theFileName)
     {
       // 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++)
       {
index 695dd905cf7708c42bbee7c11882dd74f239eb18..7050ceed46279cc1c888a3a8764d4546ebe3fae7 100644 (file)
 #ifndef OSD_Function_HeaderFile
 #define OSD_Function_HeaderFile
 
+#include <Standard_Std.hxx>
+
 // This is in fact a pointer to a function.
 // This is not an "enumeration" but a trick to solve an omission from CDL.
 
 typedef int (* OSD_Function)(...);
 
+//! Converts the given pointer to function @p theFromFunction
+//! to the type of the pointer to function specified as the first template argument @p TheToFunction.
+//! This function is necessary to explicitly mark the places where such conversion takes place
+//! and to suppress @em gcc warning @c -Wcast-function-type.
+//! @tparam TheToFunction the type to which the given pointer to function must be casted
+//! (it may be the type of the function or the type of the pointer to function)
+//! @tparam TheFromFunction the type of the function to be casted
+//! @tparam AToFunction it is not an actual template parameter,
+//! but a simple alias needed to reduce the amount of boilerplate
+//! @param theFromFunction the pointer to the function to be casted
+//! @return the pointer of the function of type @c AToFunction* that is the result of the cast
+template <typename TheToFunction,
+          typename TheFromFunction,
+          typename AToFunction = typename opencascade::std::remove_pointer<TheToFunction>::type>
+typename opencascade::std::enable_if<opencascade::std::is_function<AToFunction>::value
+                                       && opencascade::std::is_function<TheFromFunction>::value,
+                                     AToFunction*>::type
+OSD_FunctionCast (TheFromFunction* const theFromFunction)
+{
+#if defined(__GNUC__) && !defined(__INTEL_COMPILER) && !defined(__clang__)
+#  if (__GNUC__ > 8) || ((__GNUC__ == 8) && (__GNUC_MINOR__ >= 1))
+#    pragma GCC diagnostic push
+#    pragma GCC diagnostic ignored "-Wcast-function-type"
+#  endif
+#endif
+  return reinterpret_cast<AToFunction*> (theFromFunction);
+#if defined(__GNUC__) && !defined(__INTEL_COMPILER) && !defined(__clang__)
+#  if (__GNUC__ > 8) || ((__GNUC__ == 8) && (__GNUC_MINOR__ >= 1))
+#    pragma GCC diagnostic pop
+#  endif
+#endif
+}
+
 #endif
index 97d502aad7b160791b15c37683ea9781f3f587f6..593601aa916eb161885077c2fdb4a43484c5a739 100644 (file)
@@ -16,6 +16,8 @@
 
 #include <OSD_Parallel.hxx>
 
+#include <OSD_Function.hxx>
+
 #ifdef _WIN32
   #include <windows.h>
   #include <process.h>
@@ -42,7 +44,7 @@ namespace {
 
     HMODULE aKern32Module = GetModuleHandleW(L"kernel32");
     LPFN_ISWOW64PROCESS aFunIsWow64 = (aKern32Module == NULL) ? (LPFN_ISWOW64PROCESS )NULL
-      : (LPFN_ISWOW64PROCESS)GetProcAddress(aKern32Module, "IsWow64Process");
+      : OSD_FunctionCast<LPFN_ISWOW64PROCESS> (GetProcAddress(aKern32Module, "IsWow64Process"));
 
     return aFunIsWow64 != NULL &&
            aFunIsWow64(GetCurrentProcess(), &bIsWow64) &&
@@ -221,7 +223,7 @@ Standard_Integer OSD_Parallel::NbLogicalProcessors()
     typedef BOOL (WINAPI *LPFN_GSI)(LPSYSTEM_INFO );
 
     HMODULE aKern32 = GetModuleHandleW(L"kernel32");
-    LPFN_GSI aFuncSysInfo = (LPFN_GSI )GetProcAddress(aKern32, "GetNativeSystemInfo");
+    LPFN_GSI aFuncSysInfo = OSD_FunctionCast<LPFN_GSI> (GetProcAddress(aKern32, "GetNativeSystemInfo"));
 
     // So, they suggest 32-bit apps should call this instead of the other in WOW64
     if ( aFuncSysInfo != NULL )
index b635baad3157e3acf9c63e2029773f611dcccc93..0345f61efedc044108714aab49a57d4661de8bdc 100644 (file)
@@ -266,7 +266,7 @@ Standard_Boolean OSD_SharedLibrary :: DlOpen ( const OSD_LoadMode /*Mode*/ ) {
 
 OSD_Function OSD_SharedLibrary :: DlSymb ( const Standard_CString Name ) const {
 
- OSD_Function func = ( OSD_Function )GetProcAddress (  ( HMODULE )myHandle, Name  );
+ OSD_Function func = OSD_FunctionCast<OSD_Function> (GetProcAddress ((HMODULE)myHandle, Name));
 
  if ( func == NULL )
 
index ef38d808fad82c5dc72aa32a075d1b0ec978d102..f7acbd190f8b9c6d59ea806322c65462f03a698c 100644 (file)
@@ -699,12 +699,13 @@ retry:
   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))
@@ -715,23 +716,24 @@ retry:
           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)
         {
@@ -853,12 +855,13 @@ BOOL CopyDirectory (const wchar_t* dirSrc, const wchar_t* dirDst)
   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);
@@ -870,23 +873,24 @@ BOOL CopyDirectory (const wchar_t* dirSrc, const wchar_t* dirDst)
           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);
index 654523afd9a655335139a88fe2a77dbbf80f3f95..3a43672d3d46c8ec7f2bf49a43d315f7efab7b3c 100644 (file)
@@ -14,6 +14,7 @@
 
 #include <OSD.hxx>
 #include <OSD_Exception_CTRL_BREAK.hxx>
+#include <OSD_Function.hxx>
 #include <Standard_DivideByZero.hxx>
 #include <Standard_Overflow.hxx>
 #include <Standard_Assert.hxx>
@@ -273,7 +274,7 @@ static void SIGWntHandler (int signum, int sub_code)
   Standard_Mutex::Sentry aSentry (THE_SIGNAL_MUTEX); // lock the mutex to prevent simultaneous handling
   switch( signum ) {
     case SIGFPE :
-      if ( signal( signum , (void(*)(int))SIGWntHandler ) == SIG_ERR )
+      if (signal (signum, OSD_FunctionCast<void (*) (int)> (SIGWntHandler)) == SIG_ERR)
         std::cout << "signal error" << std::endl ;
       switch( sub_code ) {
         case _FPE_INVALID :
@@ -301,12 +302,12 @@ static void SIGWntHandler (int signum, int sub_code)
       }
       break ;
     case SIGSEGV :
-      if ( signal( signum, (void(*)(int))SIGWntHandler ) == SIG_ERR )
+      if (signal (signum, OSD_FunctionCast<void (*) (int)> (SIGWntHandler)) == SIG_ERR)
         std::cout << "signal error" << std::endl ;
       CallHandler( EXCEPTION_ACCESS_VIOLATION ,0,0) ;
       break ;
     case SIGILL :
-      if ( signal( signum, (void(*)(int))SIGWntHandler ) == SIG_ERR )
+      if (signal (signum, OSD_FunctionCast<void (*) (int)> (SIGWntHandler)) == SIG_ERR)
         std::cout << "signal error" << std::endl ;
       CallHandler( EXCEPTION_ILLEGAL_INSTRUCTION ,0,0) ;
       break ;
@@ -452,7 +453,7 @@ void OSD::SetSignal (OSD_SignalMode theSignalMode,
     SignalFuncType aPreviousFunc = SIG_DFL;
     if (theSignalMode == OSD_SignalMode_Set || theSignalMode == OSD_SignalMode_SetUnhandled)
     {
-      aPreviousFunc = signal(aSignalTypes[i], (SignalFuncType)SIGWntHandler);
+      aPreviousFunc = signal (aSignalTypes[i], OSD_FunctionCast<SignalFuncType> (SIGWntHandler));
     }
     if (theSignalMode == OSD_SignalMode_Unset ||
         (theSignalMode == OSD_SignalMode_SetUnhandled && aPreviousFunc != SIG_DFL && aPreviousFunc != SIG_ERR))
index c812775bcab797da2d7b3b71a19beda3acaae603..45a5cdb89a8afb9764f72c1a22235f60b7ec9307 100644 (file)
@@ -25,6 +25,7 @@
 #include <TCollection_AsciiString.hxx>
 #include <TCollection_ExtendedString.hxx>
 #include <Graphic3d_GraphicDriver.hxx>
+#include <OSD_Function.hxx>
 
 #include <memory>
 
@@ -338,15 +339,15 @@ OpenGl_Window::OpenGl_Window (const Handle(OpenGl_GraphicDriver)& theDriver,
       wglMakeCurrent (aDevCtxTmp, aRendCtxTmp);
 
       typedef const char* (WINAPI *wglGetExtensionsStringARB_t)(HDC theDeviceContext);
-      wglGetExtensionsStringARB_t aGetExtensions = (wglGetExtensionsStringARB_t  )wglGetProcAddress ("wglGetExtensionsStringARB");
+      wglGetExtensionsStringARB_t aGetExtensions = OSD_FunctionCast<wglGetExtensionsStringARB_t> (wglGetProcAddress ("wglGetExtensionsStringARB"));
       const char* aWglExts = (aGetExtensions != NULL) ? aGetExtensions (wglGetCurrentDC()) : NULL;
       if (OpenGl_Context::CheckExtension (aWglExts, "WGL_ARB_pixel_format"))
       {
-        aChoosePixProc = (wglChoosePixelFormatARB_t    )wglGetProcAddress ("wglChoosePixelFormatARB");
+        aChoosePixProc = OSD_FunctionCast<wglChoosePixelFormatARB_t> (wglGetProcAddress ("wglChoosePixelFormatARB"));
       }
       if (OpenGl_Context::CheckExtension (aWglExts, "WGL_ARB_create_context_profile"))
       {
-        aCreateCtxProc = (wglCreateContextAttribsARB_t )wglGetProcAddress ("wglCreateContextAttribsARB");
+        aCreateCtxProc = OSD_FunctionCast<wglCreateContextAttribsARB_t> (wglGetProcAddress ("wglCreateContextAttribsARB"));
       }
     }
 
@@ -525,7 +526,7 @@ OpenGl_Window::OpenGl_Window (const Handle(OpenGl_GraphicDriver)& theDriver,
     typedef GLXContext (*glXCreateContextAttribsARB_t)(Display* dpy, GLXFBConfig config,
                                                        GLXContext share_context, Bool direct,
                                                        const int* attrib_list);
-    glXCreateContextAttribsARB_t aCreateCtxProc = (glXCreateContextAttribsARB_t )glXGetProcAddress((const GLubyte* )"glXCreateContextAttribsARB");
+    glXCreateContextAttribsARB_t aCreateCtxProc = OSD_FunctionCast<glXCreateContextAttribsARB_t> (glXGetProcAddress((const GLubyte* )"glXCreateContextAttribsARB"));
     if (!theCaps->contextCompatible)
     {
       int aCoreCtxAttribs[] =
index b478296f89e56b39e46093ac6382dcc5ba0a2d73..63b1a1bbd77356f29e63c9de02edd17150fdd78f 100644 (file)
@@ -92,9 +92,8 @@ Handle(Standard_Transient) Plugin::Load (const Standard_GUID& aGUID,
   }
   else
     f = theMapOfFunctions(pid);
-  
-  Standard_Transient* (*fp) (const Standard_GUID&) = NULL;
-  fp = (Standard_Transient* (*)(const Standard_GUID&)) f;
+
+  Standard_Transient* (*fp) (const Standard_GUID&) = OSD_FunctionCast<Standard_Transient* (*)(const Standard_GUID&)> (f);
   Handle(Standard_Transient) theServiceFactory = (*fp) (aGUID);
   return theServiceFactory;
   
index 8a7ab78d2972bdabe26cfb88871c1c25bd503bdd..3d81fbf3f57aee0c6698b6dd77185eef00fa1c5e 100644 (file)
@@ -3154,7 +3154,7 @@ static Standard_Integer OCC30708_1 (Draw_Interpretor& di, Standard_Integer, cons
     it.Initialize (empty);
 
   }
-  catch (Standard_Failure)
+  catch (const Standard_Failure&)
   {
     di << "Cannot initialize TopoDS_Iterator with null shape\n";
     return 0;
@@ -3179,7 +3179,7 @@ static Standard_Integer OCC30708_2 (Draw_Interpretor& di, Standard_Integer, cons
     TopoDS_Wire empty;
     BRepLib_MakeWire aWBuilder (empty);
   }
-  catch (Standard_Failure)
+  catch (const Standard_Failure&)
   {
     di << "Cannot initialize BRepLib_MakeWire with null wire\n";
   }
index 401c89699e453e3b6efa28188ddf81fc46909c03..dfbcaea2c56cbd5fd733ac587b68bcddb7b6c193 100644 (file)
@@ -830,66 +830,6 @@ static Standard_Integer closefreebounds (Draw_Interpretor& di,
 }
 
 
-//=======================================================================
-//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)
 {
@@ -1076,10 +1016,7 @@ static Standard_Integer checkedge(Draw_Interpretor& di, Standard_Integer argc, c
   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);
   theCommands.Add ("checkedge","edge [face]", __FILE__,checkedge,g);