diff --git a/opennurbs_compress.cpp b/opennurbs_compress.cpp index 4615c49..dba46b3 100644 --- a/opennurbs_compress.cpp +++ b/opennurbs_compress.cpp @@ -131,7 +131,7 @@ bool ON_CompressStream::In( ON__UINT64 size, const void* uncompressed_buffer ) // compressed output in m_zlib.strm.next_out[], or do both. // provide storage for compressed stream output - strm.next_out = (z_Bytef*)out_buffer; + strm.next_out = (Bytef*)out_buffer; strm.avail_out = sizeof_out_buffer; if ( strm.avail_in <= 0 ) @@ -145,7 +145,7 @@ bool ON_CompressStream::In( ON__UINT64 size, const void* uncompressed_buffer ) ON__UINT64 sz = (size > max_sz) ? max_sz : size; m_in_size += sz; m_in_crc = ON_CRC32(m_in_crc,(size_t)sz,uncompressed_buffer); // (size_t) cast is safe because sz <= max_sz = 0x7FFFFFF0 - strm.next_in = (z_Bytef*)uncompressed_buffer; + strm.next_in = (Bytef*)uncompressed_buffer; strm.avail_in = (ON__UINT32)sz; uncompressed_buffer = ((const unsigned char*)uncompressed_buffer) + sz; size -= sz; @@ -155,7 +155,7 @@ bool ON_CompressStream::In( ON__UINT64 size, const void* uncompressed_buffer ) // calculate compression ON__UINT32 avail_in0 = strm.avail_in; ON__UINT32 avail_out0 = strm.avail_out; - zrc = z_deflate( &strm, Z_NO_FLUSH ); + zrc = deflate( &strm, Z_NO_FLUSH ); if ( zrc < 0 ) { // Something went haywire - bail out. @@ -238,11 +238,11 @@ bool ON_CompressStream::End() // provide storage for compressed stream output strm.avail_in = 0; strm.next_in = 0; - strm.next_out = (z_Bytef*)out_buffer; + strm.next_out = (Bytef*)out_buffer; strm.avail_out = sizeof_out_buffer; // finish compression calculation - zrc = z_deflate( &strm, Z_FINISH ); + zrc = deflate( &strm, Z_FINISH ); if ( zrc < 0 ) { // Something went haywire - bail out. @@ -449,7 +449,7 @@ bool ON_UncompressStream::In( ON__UINT64 size, const void* compressed_buffer ) // uncompressed output in strm.next_out[], or do both. // provide storage for uncompressed stream output - strm.next_out = (z_Bytef*)out_buffer; + strm.next_out = (Bytef*)out_buffer; strm.avail_out = sizeof_out_buffer; if ( strm.avail_in <= 0 ) @@ -463,7 +463,7 @@ bool ON_UncompressStream::In( ON__UINT64 size, const void* compressed_buffer ) ON__UINT64 sz = (size > max_sz) ? max_sz : size; m_in_size += sz; m_in_crc = ON_CRC32(m_in_crc,(size_t)sz,compressed_buffer); // (size_t) cast is safe because sz <= max_sz = 0x7FFFFFF0 - strm.next_in = (z_Bytef*)compressed_buffer; + strm.next_in = (Bytef*)compressed_buffer; strm.avail_in = (ON__UINT32)sz; compressed_buffer = ((const unsigned char*)compressed_buffer) + sz; size -= sz; @@ -473,7 +473,7 @@ bool ON_UncompressStream::In( ON__UINT64 size, const void* compressed_buffer ) // calculate compression ON__UINT32 avail_in0 = strm.avail_in; ON__UINT32 avail_out0 = strm.avail_out; - zrc = z_inflate( &strm, Z_NO_FLUSH ); + zrc = inflate( &strm, Z_NO_FLUSH ); if ( zrc < 0 ) { // Something went haywire - bail out. @@ -556,11 +556,11 @@ bool ON_UncompressStream::End() // provide storage for compressed stream output strm.avail_in = 0; strm.next_in = 0; - strm.next_out = (z_Bytef*)out_buffer; + strm.next_out = (Bytef*)out_buffer; strm.avail_out = sizeof_out_buffer; // finish compression calculation - zrc = z_inflate( &strm, Z_FINISH ); + zrc = inflate( &strm, Z_FINISH ); if ( zrc < 0 ) { // Something went haywire - bail out. diff --git a/opennurbs_locale.cpp b/opennurbs_locale.cpp index 45c46a5..c3281a6 100644 --- a/opennurbs_locale.cpp +++ b/opennurbs_locale.cpp @@ -1343,7 +1343,7 @@ public: static bool Validate_sprintf_l() { -#if defined(ON_COMPILER_CLANG) || defined(ON_COMPILER_GNU) +#if (defined(ON_COMPILER_CLANG) || defined(ON_COMPILER_GNU)) && !defined( ON_COMPILER_MSC) #if defined(ON_RUNTIME_ANDROID) || defined(ON_RUNTIME_LINUX) // Test formatted printing char buffer[64] = { 0 }; @@ -1368,7 +1368,7 @@ public: static bool Validate_sprintf_s_l() { -#if defined(ON_COMPILER_CLANG) || defined(ON_COMPILER_GNU) +#if (defined(ON_COMPILER_CLANG) || defined(ON_COMPILER_GNU)) && !defined( ON_COMPILER_MSC) #if defined(ON_RUNTIME_ANDROID) || defined(ON_RUNTIME_LINUX) // Test formatted printing char buffer[64] = { 0 }; @@ -1422,7 +1422,7 @@ public: static bool Validate_sscanf_l() { -#if defined(ON_COMPILER_CLANG) || defined(ON_COMPILER_GNU) +#if (defined(ON_COMPILER_CLANG) || defined(ON_COMPILER_GNU)) && !defined( ON_COMPILER_MSC) #if defined(ON_RUNTIME_ANDROID) || defined(ON_RUNTIME_LINUX) // Test formatted scanning double a = ON_UNSET_VALUE; @@ -1447,7 +1447,7 @@ public: static bool Validate_sscanf_s_l() { -#if defined(ON_COMPILER_CLANG) || defined(ON_COMPILER_GNU) +#if (defined(ON_COMPILER_CLANG) || defined(ON_COMPILER_GNU)) && !defined( ON_COMPILER_MSC) #if defined(ON_RUNTIME_ANDROID) || defined(ON_RUNTIME_LINUX) // Test formatted scanning double a = ON_UNSET_VALUE; diff --git a/opennurbs_public.sln b/opennurbs_public.sln index c192678..76183c6 100644 --- a/opennurbs_public.sln +++ b/opennurbs_public.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.27130.2020 +# Visual Studio Version 17 +VisualStudioVersion = 17.7.34031.279 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlib", "zlib\zlib.vcxproj", "{7B90C09F-DC78-42B2-AD34-380F6D466B29}" EndProject @@ -32,9 +32,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example_write", "example_wr EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "opennurbs_public", "opennurbs_public.vcxproj", "{1356641D-0B22-4123-B519-A69EE5CDC7F8}" - ProjectSection(ProjectDependencies) = postProject - {7B90C09F-DC78-42B2-AD34-380F6D466B29} = {7B90C09F-DC78-42B2-AD34-380F6D466B29} - EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "opennurbs_public_staticlib", "opennurbs_public_staticlib.vcxproj", "{23288C65-E3EB-4D09-A648-22E1636EB40F}" ProjectSection(ProjectDependencies) = postProject diff --git a/opennurbs_public.vcxproj b/opennurbs_public.vcxproj index f381c54..ed3cf67 100644 --- a/opennurbs_public.vcxproj +++ b/opennurbs_public.vcxproj @@ -69,15 +69,28 @@ - - - + + C:\;$(LLVMInstallDir)\lib\clang\$(LLVMIncludeVersion)\include;$(IncludePath) + $(ProjectName)D$(PlatformArchitecture) + + + C:\;$(LLVMInstallDir)\lib\clang\$(LLVMIncludeVersion)\include;$(IncludePath) + $(ProjectName)R$(PlatformArchitecture) + + + C:\;$(LLVMInstallDir)\lib\clang\$(LLVMIncludeVersion)\include;$(IncludePath) + $(ProjectName)D$(PlatformArchitecture) + + + C:\;$(LLVMInstallDir)\lib\clang\$(LLVMIncludeVersion)\include;$(IncludePath) + $(ProjectName)R$(PlatformArchitecture) + Use opennurbs.h Disabled - WIN32;_DEBUG;_WINDOWS;_USRDLL;OPENNURBS_EXPORTS;%(PreprocessorDefinitions) + WIN32;_DEBUG;_WINDOWS;_USRDLL;OPENNURBS_EXPORTS;ON_COMPILER_CLANG;%(PreprocessorDefinitions) ProgramDatabase true @@ -86,6 +99,11 @@ true Usp10.lib;Shlwapi.lib;Rpcrt4.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + copy $(TargetDir)$(TargetName).pdb \EgtDev\Extern\opennurbs\Lib\ +copy $(TargetDir)$(TargetName).lib \EgtDev\Extern\opennurbs\Lib\ +copy $(TargetPath) \EgtProg\DllD32 + @@ -94,7 +112,7 @@ Disabled true true - WIN32;NDEBUG;_WINDOWS;_USRDLL;OPENNURBS_EXPORTS;%(PreprocessorDefinitions) + WIN32;NDEBUG;_WINDOWS;_USRDLL;OPENNURBS_EXPORTS;ON_COMPILER_CLANG;%(PreprocessorDefinitions) true @@ -102,6 +120,11 @@ true Usp10.lib;Shlwapi.lib;Rpcrt4.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + copy $(TargetDir)$(TargetName).pdb \EgtDev\Extern\opennurbs\Lib\ +copy $(TargetDir)$(TargetName).lib \EgtDev\Extern\opennurbs\Lib\ +copy $(TargetPath) \EgtProg\Dll32 + @@ -111,13 +134,20 @@ WIN64;_DEBUG;_WINDOWS;_USRDLL;OPENNURBS_EXPORTS;__clang;ON_COMPILER_CLANG;%(PreprocessorDefinitions) true ProgramDatabase - true + false + Level1 + -Wunknown-pragmas %(AdditionalOptions) Windows true - Usp10.lib;Shlwapi.lib;Rpcrt4.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + Usp10.lib;Shlwapi.lib;Rpcrt4.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;C:\EgtDev\Extern\zlib\Lib\zlibD64.lib;%(AdditionalDependencies) + + copy $(TargetDir)$(TargetName).pdb \EgtDev\Extern\opennurbs\Lib\ +copy $(TargetDir)$(TargetName).lib \EgtDev\Extern\opennurbs\Lib\ +copy $(TargetPath) \EgtProg\DllD64 + @@ -126,7 +156,7 @@ Disabled true true - WIN64;NDEBUG;_WINDOWS;_USRDLL;OPENNURBS_EXPORTS;OPENNURBS_ZLIB_LIB_DIR="C:/EgtDev/Extern/zlib/Lib";%(PreprocessorDefinitions) + WIN64;NDEBUG;_WINDOWS;_USRDLL;OPENNURBS_EXPORTS;OPENNURBS_ZLIB_LIB_DIR="C:/EgtDev/Extern/zlib/Lib";ON_COMPILER_CLANG;%(PreprocessorDefinitions) true Level3 false @@ -137,6 +167,11 @@ true Usp10.lib;Shlwapi.lib;Rpcrt4.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + copy $(TargetDir)$(TargetName).pdb \EgtDev\Extern\opennurbs\Lib\ +copy $(TargetDir)$(TargetName).lib \EgtDev\Extern\opennurbs\Lib\ +copy $(TargetPath) \EgtProg\Dll64 + diff --git a/opennurbs_string_format.cpp b/opennurbs_string_format.cpp index 304b351..231521b 100644 --- a/opennurbs_string_format.cpp +++ b/opennurbs_string_format.cpp @@ -803,7 +803,7 @@ int ON_String::FormatVargsIntoBuffer( if (0 == buffer || buffer_capacity <= 0) return -1; buffer[0] = 0; -#if defined(ON_COMPILER_CLANG) || defined(ON_COMPILER_GNU) +#if (defined(ON_COMPILER_CLANG) || defined(ON_COMPILER_GNU)) && !defined( ON_COMPILER_MSC) // CLang modifies args so a copy is required va_list args_copy; va_copy (args_copy, args); @@ -854,7 +854,7 @@ int ON_String::FormatVargsOutputCount( if ( nullptr == format || 0 == format[0] ) return 0; -#if defined(ON_COMPILER_CLANG) || defined(ON_COMPILER_GNU) +#if ( defined(ON_COMPILER_CLANG) || defined(ON_RUNTIME_LINUX)) && !defined(ON_COMPILER_MSC) // CLang modifies args so a copy is required va_list args_copy; va_copy (args_copy, args); diff --git a/opennurbs_string_scan.cpp b/opennurbs_string_scan.cpp index 34df906..f87348e 100644 --- a/opennurbs_string_scan.cpp +++ b/opennurbs_string_scan.cpp @@ -85,7 +85,7 @@ int ON_String::ScanBufferVargs( va_list args ) { -#if defined(ON_COMPILER_CLANG) || defined(ON_RUNTIME_LINUX) +#if (defined(ON_COMPILER_CLANG) || defined(ON_RUNTIME_LINUX)) && !defined(ON_COMPILER_MSC) #if defined(ON_RUNTIME_ANDROID) || defined(ON_RUNTIME_LINUX) if (nullptr == buffer || nullptr == format) return -1; @@ -398,7 +398,7 @@ const char* ON_String::ToNumber( local_buffer[local_buffer_count++] = 0; double x = value_on_failure; -#if defined(ON_COMPILER_CLANG) || defined(ON_RUNTIME_LINUX) +#if (defined(ON_COMPILER_CLANG) || defined(ON_RUNTIME_LINUX)) && ! defined(ON_COMPILER_MSC) #if defined(ON_RUNTIME_ANDROID) || defined(ON_RUNTIME_LINUX) if (1 == sscanf(local_buffer, "%lg", &x)) { @@ -660,7 +660,7 @@ const wchar_t* ON_wString::ToNumber( local_buffer[local_buffer_count++] = 0; double x = value_on_failure; -#if defined(ON_COMPILER_CLANG) || defined(ON_RUNTIME_LINUX) +#if ( defined(ON_COMPILER_CLANG) || defined(ON_RUNTIME_LINUX)) && ! defined(ON_COMPILER_MSC) #if defined(ON_RUNTIME_ANDROID) || defined(ON_RUNTIME_LINUX) if (1 == sscanf(local_buffer, "%lg", &x)) { diff --git a/opennurbs_system.h b/opennurbs_system.h index 504fea2..1745b52 100644 --- a/opennurbs_system.h +++ b/opennurbs_system.h @@ -522,7 +522,7 @@ typedef ON__UINT32 wchar_t; #endif -#if defined(ON_COMPILER_CLANG) +#if defined(ON_COMPILER_CLANG) && !defined( ON_COMPILER_MSC) #pragma ON_PRAGMA_WARNING_BEFORE_DIRTY_INCLUDE #include #pragma ON_PRAGMA_WARNING_AFTER_DIRTY_INCLUDE diff --git a/opennurbs_system_compiler.h b/opennurbs_system_compiler.h index c03e769..bb6c904 100644 --- a/opennurbs_system_compiler.h +++ b/opennurbs_system_compiler.h @@ -86,6 +86,7 @@ ... #pragma ON_PRAGMA_WARNING_POP */ +#if !defined(__clang__) & !defined( __clang) & !defined(ON_COMPILER_CLANG) #define ON_PRAGMA_WARNING_PUSH warning( push ) #define ON_PRAGMA_WARNING_POP warning( pop ) #define ON_PRAGMA_WARNING_DISABLE_MSC(ON_PRAGMA_WARNING_DISABLE_param) warning( disable : ON_PRAGMA_WARNING_DISABLE_param ) // Microsoft CL warning disable @@ -94,6 +95,17 @@ // Microsoft, Freetype, and other external header files issue warnings we can't do anything about #define ON_PRAGMA_WARNING_BEFORE_DIRTY_INCLUDE warning( push, 1 ) #define ON_PRAGMA_WARNING_AFTER_DIRTY_INCLUDE warning( pop ) +#else +#define ON_PRAGMA_WARNING_PUSH clang diagnostic push +#define ON_PRAGMA_WARNING_POP clang diagnostic pop +#define ON_PRAGMA_WARNING_DISABLE_CLANG(ON_PRAGMA_WARNING_DISABLE_param) clang diagnostic ignored ON_PRAGMA_WARNING_DISABLE_param // Microsoft CL warning disable + +// Opennurbs warning level is /Wall +// Microsoft, Freetype, and other external header files issue warnings we can't do anything about +#define ON_PRAGMA_WARNING_BEFORE_DIRTY_INCLUDE warning( push, 1 ) +#define ON_PRAGMA_WARNING_AFTER_DIRTY_INCLUDE warning( pop ) +#endif + #if !defined(_CRT_SECURE_NO_DEPRECATE) #define _CRT_SECURE_NO_DEPRECATE @@ -170,6 +182,7 @@ #pragma ON_PRAGMA_WARNING_DISABLE_MSC(4456) #endif +#if !defined( ON_COMPILER_CLANG) // C4100 '...': unreferenced formal parameter ... #pragma ON_PRAGMA_WARNING_DISABLE_MSC(4100) @@ -184,6 +197,22 @@ // C4820 '...' bytes padding added after construct '...' #pragma ON_PRAGMA_WARNING_DISABLE_MSC(4820) +#else +// C4100 '...': unreferenced formal parameter ... +#pragma ON_PRAGMA_WARNING_DISABLE_CLANG(4100) + +// C4061 enumerator '...' in switch of enum '...' is not explicitly handled by a case label +#pragma ON_PRAGMA_WARNING_DISABLE_CLANG(4061) + +// C4062 enumerator '...' in switch of enum '...' is not handled +#pragma ON_PRAGMA_WARNING_DISABLE_CLANG(4062) + +// C4711 function '...' selected for inline expansion +#pragma ON_PRAGMA_WARNING_DISABLE_CLANG(4711) + +// C4820 '...' bytes padding added after construct '...' +#pragma ON_PRAGMA_WARNING_DISABLE_CLANG(4820) +#endif ///////////////////////////////////////////////////////////////////////////////////// // diff --git a/opennurbs_zlib.cpp b/opennurbs_zlib.cpp index 86fda61..b8eda9d 100644 --- a/opennurbs_zlib.cpp +++ b/opennurbs_zlib.cpp @@ -49,8 +49,10 @@ #pragma comment(lib, "\"" OPENNURBS_ZLIB_LIB_DIR "/" "zlib_mt.lib" "\"") #else // using Microsoft DLL C-runtime -#pragma message ( "Linking with zlib.lib in " OPENNURBS_PP2STR(OPENNURBS_ZLIB_LIB_DIR) ) -#pragma comment(lib, "\"" OPENNURBS_ZLIB_LIB_DIR "/" "zlib.lib" "\"") +//#pragma message ( "Linking with zlib.lib in " OPENNURBS_PP2STR(OPENNURBS_ZLIB_LIB_DIR) ) +//#pragma comment(lib, "\"" OPENNURBS_ZLIB_LIB_DIR "/" "zlib.lib" "\"") +//#pragma comment(lib, "\"" OPENNURBS_ZLIB_LIB_DIR "/" "zlib" "\"") +//#pragma comment(lib, "C:\\EgtDev\\Extern\\zlib\\Lib\\zlibD64.lib") #endif #endif @@ -313,7 +315,7 @@ size_t ON_BinaryArchive::WriteDeflate( // returns number of bytes written // no uncompressed input is left - switch to finish mode flush = Z_FINISH; } - zrc = z_deflate(&m_zlib.m_strm, flush); + zrc = deflate(&m_zlib.m_strm, flush); if ( zrc < 0 ) { // Something went haywire - bail out. @@ -513,7 +515,7 @@ bool ON_BinaryArchive::ReadInflate( // no compressed input is left - switch to finish mode flush = Z_FINISH; } - zrc = z_inflate( &m_zlib.m_strm, flush ); + zrc = inflate( &m_zlib.m_strm, flush ); if ( zrc < 0 ) { // Something went haywire - bail out. @@ -1183,7 +1185,7 @@ size_t ON_CompressedBuffer::DeflateHelper( // returns number of bytes written // no uncompressed input is left - switch to finish mode flush = Z_FINISH; } - zrc = z_deflate( &m_zlib.m_strm, flush ); + zrc = deflate( &m_zlib.m_strm, flush ); if ( zrc < 0 ) { // Something went haywire - bail out. @@ -1316,7 +1318,7 @@ bool ON_CompressedBuffer::InflateHelper( // no compressed input is left - switch to finish mode flush = Z_FINISH; } - zrc = z_inflate( &m_zlib.m_strm, flush ); + zrc = inflate( &m_zlib.m_strm, flush ); if ( zrc < 0 ) { // Something went haywire - bail out. diff --git a/opennurbs_zlib.h b/opennurbs_zlib.h index 5d04fb3..71fa690 100644 --- a/opennurbs_zlib.h +++ b/opennurbs_zlib.h @@ -29,23 +29,26 @@ // header files are included by opennurbs.h. -#if !defined(Z_PREFIX) -/* decorates zlib functions with a "z_" prefix to prevent symbol collision. */ -#define Z_PREFIX -#endif +//#if !defined(Z_PREFIX) +///* decorates zlib functions with a "z_" prefix to prevent symbol collision. */ +//#define Z_PREFIX +//#endif #if !defined(MY_ZCALLOC) /* have zlib use oncalloc() and onfree() for memory managment*/ #define MY_ZCALLOC #endif -#pragma ON_PRAGMA_WARNING_BEFORE_DIRTY_INCLUDE -#include "./zlib/zlib.h" -#pragma ON_PRAGMA_WARNING_AFTER_DIRTY_INCLUDE +//#pragma ON_PRAGMA_WARNING_BEFORE_DIRTY_INCLUDE +//#include "./zlib/zlib.h" +#include "C:\\EgtDev\\Extern\\zlib\\Include\\zlib.h" +//#pragma ON_PRAGMA_WARNING_AFTER_DIRTY_INCLUDE -ON_BEGIN_EXTERNC +//ON_BEGIN_EXTERNC +extern "C" { voidpf zcalloc(voidpf, unsigned, unsigned); void zcfree(voidpf, voidpf); -ON_END_EXTERNC +} +//ON_END_EXTERNC #endif