mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
0027197: Configuration - fix compilation issues when using mingw
AIS_ColorScale, AIS_Dimension - the protected method DrawText() has been renamed to drawText() to avoid name collisions with macros. _MSC_VER/_WIN32 misuse has been fixed in several places. Header <malloc.h> is now included where alloca() is used. Draw_Window - dllimport flag has been dropped from inline methods. TKernel - mandatory dependencies Winspool.lib and Psapi.lib are now linked explicitly (instead of msvc-specific pragma syntax). CMake scripts - the option -std=c++0x has been replaced by -std=gnu++0x for mingw to allow extensions (like _wfopen() and others). The minimum Windows version has been set to _WIN32_WINNT=0x0501. Invalid options "-z defs" and "-lm" have been dropped for mingw. Flag --export-all-symbols has been added to CMAKE_SHARED_LINKER_FLAGS to workaround missing vtable symbols when using mingw. FreeType is now linked explicitly on Windows. Draw::Load() - "lib" suffix is now prepended on mingw as well. Drop redundant declaration of _TINT from OSD_WNT_1.hxx. NCollection_UtfString::FromLocale() - platform-specific code has been moved to .cxx file. Draw_BasicCommands - fixed incorrect mingw64 version macros. genproj, cbp - added workaround for process argument list limits on Windows. TKSTEP linkage is failing on this platform due to too long list of files. The list of object files to link is now stored in dedicated file which is passed to gcc. Option "-z defs" removed from CMake linker options to avoid problems when building with different configurations of VTK on Linux Some MinGW-specific compiler warnings (potentially uninitialized vars, use of NULL, parentheses in conditional expressions) are fixed (speculatively)
This commit is contained in:
@@ -267,9 +267,7 @@ Standard_Boolean OSD_DirectoryIterator :: More () {
|
||||
|
||||
void OSD_DirectoryIterator :: Next () {
|
||||
|
||||
if ( myFirstCall && !( _FD -> dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) ||
|
||||
!myFirstCall
|
||||
) {
|
||||
if ( ! myFirstCall || ! ( _FD -> dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) ) {
|
||||
|
||||
do {
|
||||
|
||||
|
@@ -384,7 +384,7 @@ return OSD_UNKNOWN ;
|
||||
// --------------------------------------------------------------------------
|
||||
// Read content of a file
|
||||
// --------------------------------------------------------------------------
|
||||
void OSD_File::Read( Standard_Address& Buffer,
|
||||
void OSD_File::Read(const Standard_Address Buffer,
|
||||
const Standard_Integer Nbyte,
|
||||
Standard_Integer& Readbyte)
|
||||
{
|
||||
@@ -841,11 +841,12 @@ void OSD_File::Rewind() {
|
||||
|
||||
#if defined(__CYGWIN32__) || defined(__MINGW32__)
|
||||
#define VAC
|
||||
#define _int64 int
|
||||
#endif
|
||||
|
||||
#pragma comment( lib, "WSOCK32.LIB" )
|
||||
#pragma comment( lib, "WINSPOOL.LIB" )
|
||||
#if defined(_MSC_VER)
|
||||
#pragma comment( lib, "WSOCK32.LIB" )
|
||||
#pragma comment( lib, "WINSPOOL.LIB" )
|
||||
#endif
|
||||
|
||||
#define ACE_HEADER_SIZE ( sizeof ( ACCESS_ALLOWED_ACE ) - sizeof ( DWORD ) )
|
||||
|
||||
@@ -1085,19 +1086,18 @@ void OSD_File :: Read (
|
||||
}
|
||||
|
||||
Standard_Integer NbyteRead;
|
||||
Standard_Address buff;
|
||||
|
||||
TEST_RAISE( "Read" );
|
||||
|
||||
buff = ( Standard_Address )new Standard_Character[ Nbyte + 1 ];
|
||||
char* buff = new Standard_Character[ Nbyte + 1 ];
|
||||
|
||||
Read ( buff, Nbyte, NbyteRead );
|
||||
|
||||
( ( Standard_PCharacter )buff )[ NbyteRead ] = 0;
|
||||
buff[ NbyteRead ] = 0;
|
||||
|
||||
if ( NbyteRead != 0 )
|
||||
|
||||
Buffer = ( Standard_PCharacter )buff;
|
||||
Buffer = buff;
|
||||
|
||||
else
|
||||
|
||||
@@ -1259,7 +1259,7 @@ void OSD_File :: ReadLine (
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
void OSD_File :: Read (
|
||||
Standard_Address& Buffer,
|
||||
const Standard_Address Buffer,
|
||||
const Standard_Integer Nbyte, Standard_Integer& Readbyte
|
||||
) {
|
||||
|
||||
@@ -1456,7 +1456,7 @@ OSD_KindFile OSD_File :: KindOfFile () const {
|
||||
typedef struct _osd_wnt_key {
|
||||
|
||||
HKEY hKey;
|
||||
LPTSTR keyPath;
|
||||
const char* keyPath;
|
||||
|
||||
} OSD_WNT_KEY;
|
||||
|
||||
@@ -1627,23 +1627,26 @@ Standard_Boolean OSD_File :: IsLocked () {
|
||||
// Return size of a file
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
Standard_Size OSD_File :: Size () {
|
||||
|
||||
Standard_Integer retVal;
|
||||
|
||||
TEST_RAISE( "Size" );
|
||||
|
||||
LARGE_INTEGER aSize;
|
||||
aSize.QuadPart = 0;
|
||||
retVal = GetFileSizeEx (myFileHandle, &aSize);
|
||||
|
||||
if ( retVal == 0 )
|
||||
|
||||
_osd_wnt_set_error ( myError, OSD_WFile );
|
||||
|
||||
return (Standard_Size)aSize.QuadPart;
|
||||
|
||||
} // end OSD_File :: Size
|
||||
Standard_Size OSD_File::Size()
|
||||
{
|
||||
TEST_RAISE("Size");
|
||||
#if (_WIN32_WINNT >= 0x0500)
|
||||
LARGE_INTEGER aSize;
|
||||
aSize.QuadPart = 0;
|
||||
if (GetFileSizeEx (myFileHandle, &aSize) == 0)
|
||||
{
|
||||
_osd_wnt_set_error (myError, OSD_WFile);
|
||||
}
|
||||
return (Standard_Size)aSize.QuadPart;
|
||||
#else
|
||||
DWORD aSize = GetFileSize (myFileHandle, NULL);
|
||||
if (aSize == INVALID_FILE_SIZE)
|
||||
{
|
||||
_osd_wnt_set_error (myError, OSD_WFile);
|
||||
}
|
||||
return aSize;
|
||||
#endif
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Print contains of a file
|
||||
@@ -1701,9 +1704,9 @@ PSECURITY_DESCRIPTOR __fastcall _osd_wnt_protection_to_sd (
|
||||
DWORD dwAccessOwner;
|
||||
DWORD dwAccessWorld;
|
||||
DWORD dwAccessAdminDir;
|
||||
DWORD dwAccessGroupDir;
|
||||
// DWORD dwAccessGroupDir;
|
||||
DWORD dwAccessOwnerDir;
|
||||
DWORD dwAccessWorldDir;
|
||||
// DWORD dwAccessWorldDir;
|
||||
DWORD dwACLsize = sizeof ( ACL );
|
||||
DWORD dwIndex = 0;
|
||||
PTOKEN_OWNER pTkOwner = NULL;
|
||||
@@ -1769,9 +1772,9 @@ retry:
|
||||
dwAccessWorld = _get_access_mask ( prot.World () );
|
||||
|
||||
dwAccessAdminDir = _get_dir_access_mask ( prot.System () );
|
||||
dwAccessGroupDir = _get_dir_access_mask ( prot.Group () );
|
||||
// dwAccessGroupDir = _get_dir_access_mask ( prot.Group () );
|
||||
dwAccessOwnerDir = _get_dir_access_mask ( prot.User () );
|
||||
dwAccessWorldDir = _get_dir_access_mask ( prot.World () );
|
||||
// dwAccessWorldDir = _get_dir_access_mask ( prot.World () );
|
||||
|
||||
if ( dwAccessGroup != 0 ) {
|
||||
|
||||
|
@@ -117,7 +117,7 @@ public:
|
||||
//! may be less than Nbyte if the number of bytes left in the file
|
||||
//! is less than Nbyte bytes. For this reason the output
|
||||
//! parameter Readbyte will contain the number of read bytes.
|
||||
Standard_EXPORT void Read (Standard_Address& Buffer, const Standard_Integer Nbyte, Standard_Integer& Readbyte);
|
||||
Standard_EXPORT void Read (const Standard_Address Buffer, const Standard_Integer Nbyte, Standard_Integer& Readbyte);
|
||||
|
||||
//! Attempts to write Nbyte bytes from the AsciiString to the file
|
||||
//! associated to the object File.
|
||||
|
@@ -345,9 +345,7 @@ Standard_Boolean OSD_FileIterator :: More () {
|
||||
|
||||
void OSD_FileIterator :: Next () {
|
||||
|
||||
if ( myFirstCall && ( _FD -> dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) ||
|
||||
!myFirstCall
|
||||
) {
|
||||
if ( ! myFirstCall || ( _FD -> dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) ) {
|
||||
|
||||
do {
|
||||
|
||||
|
@@ -187,7 +187,9 @@ Standard_Integer OSD_Host::Error()const{
|
||||
|
||||
#include <OSD_Host.hxx>
|
||||
|
||||
#pragma comment( lib, "WSOCK32.LIB" )
|
||||
#if defined(_MSC_VER)
|
||||
#pragma comment( lib, "WSOCK32.LIB" )
|
||||
#endif
|
||||
|
||||
void _osd_wnt_set_error ( OSD_Error&, OSD_WhoAmI, ... );
|
||||
|
||||
|
@@ -58,11 +58,18 @@ void OSD_MemInfo::Update()
|
||||
myCounters[anIter] = Standard_Size(-1);
|
||||
}
|
||||
|
||||
#if (defined(_WIN32) || defined(__WIN32__))
|
||||
#if defined(_WIN32)
|
||||
#if (_WIN32_WINNT >= 0x0500)
|
||||
MEMORYSTATUSEX aStatEx;
|
||||
aStatEx.dwLength = sizeof(aStatEx);
|
||||
GlobalMemoryStatusEx (&aStatEx);
|
||||
myCounters[MemVirtual] = Standard_Size(aStatEx.ullTotalVirtual - aStatEx.ullAvailVirtual);
|
||||
#else
|
||||
MEMORYSTATUS aStat;
|
||||
aStat.dwLength = sizeof(aStat);
|
||||
GlobalMemoryStatus (&aStat);
|
||||
myCounters[MemVirtual] = Standard_Size(aStat.dwTotalVirtual - aStat.dwAvailVirtual);
|
||||
#endif
|
||||
|
||||
// use Psapi library
|
||||
HANDLE aProcess = GetCurrentProcess();
|
||||
|
@@ -11,6 +11,10 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include <OSD_OpenFile.hxx>
|
||||
#include <TCollection_ExtendedString.hxx>
|
||||
#include <NCollection_UtfString.hxx>
|
||||
@@ -23,7 +27,7 @@ FILE* OSD_OpenFile(const char* theName,
|
||||
const char* theMode)
|
||||
{
|
||||
FILE* aFile = 0;
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
// file name is treated as UTF-8 string and converted to UTF-16 one
|
||||
const TCollection_ExtendedString aFileNameW (theName, Standard_True);
|
||||
const TCollection_ExtendedString aFileModeW (theMode, Standard_True);
|
||||
@@ -43,7 +47,7 @@ FILE* OSD_OpenFile(const TCollection_ExtendedString& theName,
|
||||
const char* theMode)
|
||||
{
|
||||
FILE* aFile = 0;
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
const TCollection_ExtendedString aFileModeW (theMode, Standard_True);
|
||||
aFile = ::_wfopen ((const wchar_t* )theName.ToExtString(),
|
||||
(const wchar_t* )aFileModeW.ToExtString());
|
||||
@@ -63,7 +67,7 @@ void OSD_OpenFileBuf(std::filebuf& theBuff,
|
||||
const char* theName,
|
||||
const std::ios_base::openmode theMode)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32) && defined(_MSC_VER)
|
||||
// file name is treated as UTF-8 string and converted to UTF-16 one
|
||||
const TCollection_ExtendedString aFileNameW (theName, Standard_True);
|
||||
theBuff.open ((const wchar_t* )aFileNameW.ToExtString(), theMode);
|
||||
@@ -80,7 +84,7 @@ void OSD_OpenFileBuf(std::filebuf& theBuff,
|
||||
const TCollection_ExtendedString& theName,
|
||||
const std::ios_base::openmode theMode)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32) && defined(_MSC_VER)
|
||||
theBuff.open ((const wchar_t* )theName.ToExtString(), theMode);
|
||||
#else
|
||||
// conversion in UTF-8 for linux
|
||||
@@ -97,7 +101,7 @@ void OSD_OpenStream(std::ofstream& theStream,
|
||||
const char* theName,
|
||||
const std::ios_base::openmode theMode)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32) && defined(_MSC_VER)
|
||||
// file name is treated as UTF-8 string and converted to UTF-16 one
|
||||
const TCollection_ExtendedString aFileNameW (theName, Standard_True);
|
||||
theStream.open ((const wchar_t* )aFileNameW.ToExtString(), theMode);
|
||||
@@ -114,7 +118,7 @@ void OSD_OpenStream(std::ofstream& theStream,
|
||||
const TCollection_ExtendedString& theName,
|
||||
const std::ios_base::openmode theMode)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32) && defined(_MSC_VER)
|
||||
theStream.open ((const wchar_t* )theName.ToExtString(), theMode);
|
||||
#else
|
||||
// conversion in UTF-8 for linux
|
||||
@@ -131,7 +135,7 @@ void OSD_OpenStream (std::ifstream& theStream,
|
||||
const char* theName,
|
||||
const std::ios_base::openmode theMode)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32) && defined(_MSC_VER)
|
||||
// file name is treated as UTF-8 string and converted to UTF-16 one
|
||||
const TCollection_ExtendedString aFileNameW (theName, Standard_True);
|
||||
theStream.open ((const wchar_t*)aFileNameW.ToExtString(), theMode);
|
||||
@@ -148,7 +152,7 @@ void OSD_OpenStream (std::ifstream& theStream,
|
||||
const TCollection_ExtendedString& theName,
|
||||
const std::ios_base::openmode theMode)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32) && defined(_MSC_VER)
|
||||
theStream.open ((const wchar_t*)theName.ToExtString(), theMode);
|
||||
#else
|
||||
// conversion in UTF-8 for linux
|
||||
|
@@ -1103,7 +1103,7 @@ Standard_Integer OSD_Path :: TrekLength () const {
|
||||
Standard_Integer i = 1;
|
||||
Standard_Integer retVal = 0;
|
||||
|
||||
if ( myTrek.IsEmpty () || myTrek.Length () == 1 && myTrek.Value ( 1 ) == '|' )
|
||||
if ( myTrek.IsEmpty () || (myTrek.Length () == 1 && myTrek.Value ( 1 ) == '|') )
|
||||
|
||||
return retVal;
|
||||
|
||||
|
@@ -197,8 +197,9 @@ Standard_Integer OSD_Process::Error()const{
|
||||
#include <OSD_WNT_1.hxx>
|
||||
#include <LMCONS.H> /// pour UNLEN ( see MSDN about GetUserName() )
|
||||
|
||||
|
||||
#pragma warning( disable : 4700 )
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning( disable : 4700 )
|
||||
#endif
|
||||
|
||||
void _osd_wnt_set_error ( OSD_Error&, OSD_WhoAmI, ... );
|
||||
|
||||
|
@@ -35,10 +35,6 @@
|
||||
# endif
|
||||
# endif /* OSDAPI */
|
||||
|
||||
#if defined(__CYGWIN32__) || defined(__MINGW32__)
|
||||
#define _TINT int
|
||||
#endif
|
||||
|
||||
# ifdef __cplusplus
|
||||
extern "C" {
|
||||
# endif /* __cplusplus */
|
||||
|
@@ -24,6 +24,12 @@
|
||||
#endif
|
||||
#include <windows.h>
|
||||
|
||||
#ifndef STATUS_FLOAT_MULTIPLE_FAULTS
|
||||
// <ntstatus.h>
|
||||
#define STATUS_FLOAT_MULTIPLE_FAULTS (0xC00002B4L)
|
||||
#define STATUS_FLOAT_MULTIPLE_TRAPS (0xC00002B5L)
|
||||
#endif
|
||||
|
||||
#include <OSD_Exception_ACCESS_VIOLATION.hxx>
|
||||
#include <OSD_Exception_ARRAY_BOUNDS_EXCEEDED.hxx>
|
||||
#include <OSD_Exception_ILLEGAL_INSTRUCTION.hxx>
|
||||
|
Reference in New Issue
Block a user