0024234: occt master is not compiled by VC++ 2005 (vc8 32/64 bit TKBO)
authorabv <abv@opencascade.com>
Wed, 30 Oct 2013 20:44:20 +0000 (00:44 +0400)
committerbugmaster <bugmaster@opencascade.com>
Thu, 31 Oct 2013 11:31:05 +0000 (15:31 +0400)
Fixed building by VS 2005 and VS 2013 (Express):
- macro _WIN32_WINNT defined in BOPCol_TBB.hxx for building with TBB on VS 2005
- compiler warnings specific for VS 2005 (vc8) fixed (explicit casts added in assignment expressions involving small integer types)
- definition of functions atanh, acosh, asinh is avoided for vc12 and later (they are provided by CRT in vc12)
- math constants (M_PI and similar) are defined by including math.h rather than by custom code
- misuse of stream operator << fixed in a few places

14 files changed:
src/BOPCol/BOPCol_TBB.hxx
src/BSplSLib/BSplSLib.cxx
src/DDF/DDF_IOStream.cxx
src/FSD/FSD_File.cxx
src/Graphic3d/Graphic3d_MarkerImage.cxx
src/IGESData/IGESData_IGESWriter.cxx
src/IGESFile/liriges.c
src/ShapeFix/ShapeFix_ComposeShell.cxx
src/Standard/Standard_GUID.cxx
src/Standard/Standard_math.cxx
src/Standard/Standard_math.hxx
src/TDataStd/TDataStd_Integer.cxx
src/TopOpeBRepDS/TopOpeBRepDS_ProcessFaceInterferences.cxx
src/XmlObjMgt/XmlObjMgt.cxx

index 7a3e7179a2ce6a37a4d0a2f7fbbbc77d6892df14..b4b0d9e7cd1fd0e3908658af575e397f5cc31e64 100644 (file)
 
 #ifdef HAVE_TBB
 
+// On Windows, function TryEnterCriticalSection has appeared in Windows NT
+// and is surrounded by #ifdef in MS VC++ 7.1 headers.
+// Thus to use it we need to define appropriate macro saying that we wil
+// run on Windows NT 4.0 at least
+#if ((defined(_WIN32) || defined(__WIN32__)) && !defined(_WIN32_WINNT))
+  #define _WIN32_WINNT 0x0501
+#endif
 
 #include <tbb/tbb.h>
 using namespace tbb;
@@ -28,7 +35,6 @@ using namespace tbb;
 #define flexible_range blocked_range
 #define flexible_for   parallel_for
 
-
 #else // not HAVE_TBB
 
 #define flexible_range serial_range
index e3d4127378c2a71a7882ccc6d5209934231286d1..cc42fe9b372337cbed22d71fea4f2db5c48e4c19 100755 (executable)
@@ -39,9 +39,6 @@
 
 // for null derivatives
 static Standard_Real BSplSLib_zero[3] = {0.0, 0.0, 0.0};
-#ifdef WNT
-#define M_SQRT2 1.4142135623730950488016887 
-#endif
 
 //=======================================================================
 //struct : BSplCLib_DataContainer 
index bb1b70da58fbcbc4be9fff984e63aa4740ac9485..50d8285461fa53c0caa4de78a24aea34c820dce9 100755 (executable)
@@ -258,8 +258,7 @@ void DDF_IOStream::ReadExtendedLine(TCollection_ExtendedString& buffer)
     myIStream->get(c);
     check++; 
 //    if (!(check % 2)) Storage_StreamExtCharParityError::Raise();
-    i = 0; j = 0;
-    i += (Standard_ExtCharacter)c;
+    i = (Standard_ExtCharacter)c;
     if (c == '\0') fin = Standard_True;
     i = (i << 8);
 
@@ -267,7 +266,7 @@ void DDF_IOStream::ReadExtendedLine(TCollection_ExtendedString& buffer)
     check++;
 //    if ((check % 2) != 0) Storage_StreamExtCharParityError::Raise();
 //    cout << check << endl;
-    j += (Standard_ExtCharacter)c;
+    j = (Standard_ExtCharacter)c;
     if (c != '\n') fin = Standard_False;
     i |= (0x00FF & j);
     buffer += (Standard_ExtCharacter)i;
index 33c320c9192c958c94581da6839a9b13728d3a74..2d57ecdce39cf5d32b1e4a3ff07c7959debfe9f7 100755 (executable)
@@ -237,8 +237,8 @@ void FSD_File::ReadExtendedLine(TCollection_ExtendedString& buffer)
     if (c == tg[count]) count++;
     else count = 0;
     if (count < SIZEOFNORMALEXTENDEDSECTION) {
-      i = 0; j = 0;
-      i += (Standard_ExtCharacter)c;
+      j = 0;
+      i = (Standard_ExtCharacter)c;
       if (c == '\0') fin = Standard_True;
       i = (i << 8);
       
@@ -246,7 +246,7 @@ void FSD_File::ReadExtendedLine(TCollection_ExtendedString& buffer)
       if (c == tg[count]) count++;
       else count = 0;
       if (count < SIZEOFNORMALEXTENDEDSECTION) {
-       j += (Standard_ExtCharacter)c;
+       j = (Standard_ExtCharacter)c;
        if (c != '\n') {
          fin = Standard_False;
          i |= (0x00FF & j);
index 924cd356023ad6ebe2bd42fff069ba79a807b023..bd745572cf9ba9d59d827d513643175213e944fa 100644 (file)
@@ -111,7 +111,9 @@ Handle(TColStd_HArray1OfByte) Graphic3d_MarkerImage::GetBitMapArray (const Stand
         aBitOn = anAlphaValue > theAlphaValue;
       }
 
-      aBitMap->ChangeValue (aNumOfBytesInRow * aRow + aColumn / 8) += aBitOn ? (0x80 >> (aColumn % 8)) : 0;
+      Standard_Integer anIndex = aNumOfBytesInRow * aRow + aColumn / 8;
+      aBitMap->SetValue (anIndex, (Standard_Byte)(aBitMap->Value (anIndex) + 
+                                                  (aBitOn ? (0x80 >> (aColumn % 8)) : 0)));
     }
   }
 
index b62e97ac3e8c76d58a5905d055a73276366dd222..9c1ab520a20dc3bc126f699ed98b359b044e073e 100755 (executable)
@@ -461,7 +461,7 @@ static void writefnes (Standard_OStream& S, const Standard_CString ligne)
   char val;
   for (Standard_Integer i = 0; i < 80; i ++) {
     if (ligne[i] == '\0') return;
-    val = ligne[i] ^ (150 + (i & 3));
+    val = (char)(ligne[i] ^ (150 + (i & 3)));
     S << val;
   }
 }
@@ -487,7 +487,11 @@ Standard_Boolean IGESData_IGESWriter::Print (Standard_OStream& S) const
   Standard_Integer i; // svv Jan11 2000 : porting on DEC
   for (i = 0; i < MaxcarsG; i ++) blancs[i] = ' ';
   blancs[MaxcarsG] = '\0';
-  if (fnes) for (i = 0; i < MaxcarsG; i ++) blancs[i] = blancs[i] ^ (150 + (i & 3));
+  if (fnes)
+  {
+    for (i = 0; i < MaxcarsG; i ++)
+      blancs[i] = (char)(blancs[i] ^ (150 + (i & 3)));
+  }
 
   if (thesect != 4) Interface_InterfaceError::Raise
     ("IGESWriter not ready for Print");
index fd73af2fe6843427d64679128d1b2d7017c3d8b6..93cba1b2155307d113148961f83b73416bd3fbb1 100755 (executable)
@@ -70,7 +70,8 @@ int  iges_lire (FILE* lefic, int *numsec, char ligne[100], int modefnes)
       }
     }
     if ((ligne[0] & 128)&&modefnes) {
-      for (i = 0; i < 80; i ++)  ligne[i] = ligne[i] ^ (150 + (i & 3));
+      for (i = 0; i < 80; i ++)
+        ligne[i] = (char)(ligne[i] ^ (150 + (i & 3)));
     }
   }
   if (feof(lefic)) return 0;
index 9386e968751a55d3bd302c7f2257fde6f803f4b4..9caf50ddc33605572271d20174d48d3c2319d4e8 100755 (executable)
@@ -699,7 +699,7 @@ Standard_Integer ShapeFix_ComposeShell::ComputeCode (const Handle(ShapeExtend_Wi
     code = IOR_LEFT;
     myStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_FAIL2 );
 #ifdef DEB
-    cout << "Warning: ShapeFix_ComposeShell::ComputeCode: lost intersection point" << cout;
+    cout << "Warning: ShapeFix_ComposeShell::ComputeCode: lost intersection point" << endl;
 #endif
   }
   return code;
index f87342f9ae60197479a182b302ef9160d2b17433..c4f2b0b4eccfe5d4221c48ca885671b90cf316bf 100755 (executable)
@@ -357,8 +357,8 @@ Standard_UUID Standard_GUID::ToUUID() const
   result.Data1 = my32b ;
   result.Data2 = my16b1 ;
   result.Data3 = my16b2 ;
-  result.Data4[0] = my16b3 >> 8 ;
-  result.Data4[1] = (char ) my16b3 ;
+  result.Data4[0] = (unsigned char)(my16b3 >> 8);
+  result.Data4[1] = (char) my16b3;
   result.Data4[2] = my8b1 ;
   result.Data4[3] = my8b2 ;
   result.Data4[4] = my8b3 ;
index 565ebcab0c96ca8117d26ab92c324a622255ad18..df50e461cf0b25958164b8818550126d17ee22c7 100755 (executable)
 // purpose or non-infringement. Please see the License for the specific terms
 // and conditions governing the rights and limitations under the License.
 
-// -------------------------------------------------------------------------
-// Definition des fonctions mathematiques hyperboliques: acosh, asinh, atanh
-// pour Windows/NT uniquement.
-// -------------------------------------------------------------------------
-#ifdef WNT
-#include <math.h>
 #include <Standard_math.hxx>
 
-#ifndef _Standard_MacroHeaderFile
-# include <Standard_Macro.hxx>
-#endif  // _Standard_MacroHeaderFile
+// MSVC versions prior to 12 did not provided acosh, asinh, atanh functions in standard library
+#if defined(_MSC_VER) && (_MSC_VER < 1800)
 
 Standard_EXPORT double  __cdecl acosh( double X)
 {
@@ -53,4 +46,5 @@ Standard_EXPORT double __cdecl  atanh( double X)
        res = log((1 + X) / (1 - X)) / 2;
        return res;
 };
+
 #endif
index 3baa6c3a5e32bfeb69e5f53879d0411d1ea0931d..9ab1531892cb71d4e810add3d848ed90b0e7364c 100755 (executable)
 #include <Standard_Macro.hxx>
 #endif
 
-#ifdef WNT
+#ifdef _MSC_VER
 
-# ifndef __MATH_WNT_H
-#  define __MATH_WNT_H
+#define _USE_MATH_DEFINES
+#include <math.h>
 
+// MSVC versions prior to 12 did not provided acosh, asinh, atanh functions in standard library
+#if _MSC_VER < 1800
 __Standard_API double __cdecl acosh ( double );
 __Standard_API double __cdecl asinh ( double );
 __Standard_API double __cdecl atanh ( double );
+#endif
 
-# ifdef M_SQRT1_2
-#  undef M_SQRT1_2
-# endif
-# define M_SQRT1_2  0.707106781186547524401
-
-# ifdef M_PI_2
-#  undef M_PI_2
-# endif 
-# define M_PI_2     1.57079632679489661923
-
-# ifdef M_PI
-#  undef M_PI
-# endif
-# define M_PI       3.14159265358979323846
-
-# endif  /* __MATH_WNT_H */
-
-#endif  /* WNT */
+#endif  /* _MSC_VER */
 
index c8d65d1788fe4dd96f5cd859f3bae02083caec2b..e946345707c118809e76771101f987d7e743d413 100755 (executable)
@@ -147,7 +147,7 @@ Standard_OStream& TDataStd_Integer::Dump (Standard_OStream& anOS) const
   anOS << myValue; 
 //
   anOS <<"\nAttribute fields: ";
-  anOS << TDF_Attribute::Dump(anOS);
+  TDF_Attribute::Dump(anOS);
   return anOS;
 }
 
index c9b023c1d7132a5efe34cf53089c8a6cf00bcd1f..dc25043cdd3ecad7352733d495813692f72fe855 100755 (executable)
@@ -452,7 +452,11 @@ Standard_Boolean TestTransition(const TopOpeBRepDS_Transition& T,const TopoDS_Fa
   
   if(!transok) {
     cout<<"States found by classifier :"<<endl;
-    cout<<"Before  :"<<TopAbs::Print(stb, cout)<<"After  :"<<TopAbs::Print(sta, cout)<<endl;
+       cout << "Before  :";
+       TopAbs::Print(stb, cout);
+       cout << "After  :";
+       TopAbs::Print(sta, cout);
+       cout << endl;
   }
   
   return transok;
index 61a2a51ab100d0ed924daca9dd2ff00209027cce..6a3c8e568941e2afbd2e543d925ab9f4e43a84dc 100755 (executable)
@@ -92,7 +92,7 @@ void SprintfExtStr(char * out, const TCollection_ExtendedString& theString) {
   while (len) {
     for(int j = 0,k=3; j<4; j++,k--) {
       unsigned short v = *(p+i) & mask[j];//x000
-      v = v >> (4*k);
+      v = (unsigned short)(v >> (4*k));
       if(v < 10)
        v |= 0x30;
       else