diff --git a/extras/Build/CMake/JUCEHelperTargets.cmake b/extras/Build/CMake/JUCEHelperTargets.cmake index ec50ffea43..2cbeb2efa5 100644 --- a/extras/Build/CMake/JUCEHelperTargets.cmake +++ b/extras/Build/CMake/JUCEHelperTargets.cmake @@ -21,7 +21,7 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") -Wunreachable-code -Wzero-as-null-pointer-constant -Wcast-align -Wno-implicit-fallthrough -Wno-maybe-uninitialized -Wno-missing-field-initializers -Wno-ignored-qualifiers -Wswitch-enum - -Wswitch-default -Wredundant-decls) + -Wredundant-decls) if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "7.0.0") target_compile_options(juce_recommended_warning_flags INTERFACE "-Wno-strict-overflow") diff --git a/extras/Build/CMake/JUCEUtils.cmake b/extras/Build/CMake/JUCEUtils.cmake index 14867b4cc0..a8a3464595 100644 --- a/extras/Build/CMake/JUCEUtils.cmake +++ b/extras/Build/CMake/JUCEUtils.cmake @@ -549,9 +549,19 @@ function(juce_add_module module_path) _juce_link_libs_from_metadata("${module_name}" "${metadata_dict}" linuxLibs) elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows") - target_compile_options(${module_name} INTERFACE /bigobj) + if((CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") OR (CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC")) + if(module_name STREQUAL "juce_gui_basics") + target_compile_options(${module_name} INTERFACE /bigobj) + endif() + + _juce_link_libs_from_metadata("${module_name}" "${metadata_dict}" windowsLibs) + elseif(MSYS OR MINGW) + if(module_name STREQUAL "juce_gui_basics") + target_compile_options(${module_name} INTERFACE "-Wa,-mbig-obj") + endif() - _juce_link_libs_from_metadata("${module_name}" "${metadata_dict}" windowsLibs) + _juce_link_libs_from_metadata("${module_name}" "${metadata_dict}" mingwLibs) + endif() endif() _juce_get_metadata("${metadata_dict}" dependencies module_dependencies) diff --git a/extras/Projucer/Source/ComponentEditor/jucer_BinaryResources.cpp b/extras/Projucer/Source/ComponentEditor/jucer_BinaryResources.cpp index a1c4fd9e1e..4d3af41a32 100644 --- a/extras/Projucer/Source/ComponentEditor/jucer_BinaryResources.cpp +++ b/extras/Projucer/Source/ComponentEditor/jucer_BinaryResources.cpp @@ -241,7 +241,7 @@ void BinaryResources::loadFromCpp (const File& cppFileLocation, const String& cp if (c >= '0' && c <= '9') { - n = n * 10 + (c - '0'); + n = n * 10 + (int) (c - '0'); } else if (c == ',') { diff --git a/extras/Projucer/Source/LiveBuildEngine/jucer_CompileEngineServer.cpp b/extras/Projucer/Source/LiveBuildEngine/jucer_CompileEngineServer.cpp index f97f0e8736..1fa4bf911d 100644 --- a/extras/Projucer/Source/LiveBuildEngine/jucer_CompileEngineServer.cpp +++ b/extras/Projucer/Source/LiveBuildEngine/jucer_CompileEngineServer.cpp @@ -283,7 +283,7 @@ void sendQuitMessageToIDE (void* server) #define WIN32_LEAN_AND_MEAN 1 #include - static HANDLE parentProcessHandle = 0; + static HANDLE parentProcessHandle = nullptr; static void setParentProcessID (int pid) { parentProcessHandle = OpenProcess (SYNCHRONIZE, FALSE, (DWORD) pid); } static int getCurrentProcessID() { return (int) GetCurrentProcessId(); } #endif diff --git a/extras/Projucer/Source/LiveBuildEngine/jucer_CppHelpers.h b/extras/Projucer/Source/LiveBuildEngine/jucer_CppHelpers.h index 60230ced8d..9a5b8b30c4 100644 --- a/extras/Projucer/Source/LiveBuildEngine/jucer_CppHelpers.h +++ b/extras/Projucer/Source/LiveBuildEngine/jucer_CppHelpers.h @@ -45,7 +45,7 @@ struct CppParserHelpers for (int i = 0; i < text.length(); ++i) { - const int digit = text[i] - '0'; + const auto digit = (int) (text[i] - '0'); if (digit < 0 || digit > 7) break; diff --git a/extras/Projucer/Source/Utility/Helpers/jucer_TranslationHelpers.h b/extras/Projucer/Source/Utility/Helpers/jucer_TranslationHelpers.h index 1cdc66e465..8c9d8c60db 100644 --- a/extras/Projucer/Source/Utility/Helpers/jucer_TranslationHelpers.h +++ b/extras/Projucer/Source/Utility/Helpers/jucer_TranslationHelpers.h @@ -117,7 +117,7 @@ struct TranslationHelpers break; ++p; - c = (juce_wchar) ((c << 4) + digitValue); + c = (c << 4) + (juce_wchar) digitValue; } break; @@ -128,12 +128,12 @@ struct TranslationHelpers for (int i = 4; --i >= 0;) { - const int digitValue = *p - '0'; + const auto digitValue = (int) (*p - '0'); if (digitValue < 0 || digitValue > 7) break; ++p; - c = (juce_wchar) ((c << 3) + digitValue); + c = (c << 3) + (juce_wchar) digitValue; } break; diff --git a/modules/juce_core/memory/juce_MemoryBlock.cpp b/modules/juce_core/memory/juce_MemoryBlock.cpp index 2d1e2406c0..e565bb1435 100644 --- a/modules/juce_core/memory/juce_MemoryBlock.cpp +++ b/modules/juce_core/memory/juce_MemoryBlock.cpp @@ -321,7 +321,7 @@ void MemoryBlock::loadFromHexString (StringRef hex) for (;;) { - int byte = 0; + juce_wchar byte = 0; for (int loop = 2; --loop >= 0;) { diff --git a/modules/juce_core/native/juce_win32_ComSmartPtr.h b/modules/juce_core/native/juce_win32_ComSmartPtr.h index 2316d24292..67846965d4 100644 --- a/modules/juce_core/native/juce_win32_ComSmartPtr.h +++ b/modules/juce_core/native/juce_win32_ComSmartPtr.h @@ -56,7 +56,7 @@ inline GUID uuidFromString (const char* s) noexcept for (uint32 digitIndex = 0; digitIndex < 32;) { - auto c = *s++; + auto c = (uint32) *s++; uint32 digit; if (c >= '0' && c <= '9') digit = c - '0'; @@ -114,7 +114,7 @@ public: HRESULT CoCreateInstance (REFCLSID classUUID, DWORD dwClsContext = CLSCTX_INPROC_SERVER) { - auto hr = ::CoCreateInstance (classUUID, 0, dwClsContext, __uuidof (ComClass), (void**) resetAndGetPointerAddress()); + auto hr = ::CoCreateInstance (classUUID, nullptr, dwClsContext, __uuidof (ComClass), (void**) resetAndGetPointerAddress()); jassert (hr != CO_E_NOTINITIALIZED); // You haven't called CoInitialize for the current thread! return hr; } diff --git a/modules/juce_core/native/juce_win32_Files.cpp b/modules/juce_core/native/juce_win32_Files.cpp index 46c1e15dbe..e0701dadc0 100644 --- a/modules/juce_core/native/juce_win32_Files.cpp +++ b/modules/juce_core/native/juce_win32_Files.cpp @@ -131,7 +131,7 @@ namespace WindowsFileHelpers { WCHAR path[MAX_PATH + 256]; - if (SHGetSpecialFolderPath (0, path, type, FALSE)) + if (SHGetSpecialFolderPath (nullptr, path, type, FALSE)) return File (String (path)); return {}; @@ -264,14 +264,14 @@ bool File::replaceInternal (const File& dest) const { return ReplaceFile (dest.getFullPathName().toWideCharPointer(), fullPath.toWideCharPointer(), - 0, REPLACEFILE_IGNORE_MERGE_ERRORS | 4 /*REPLACEFILE_IGNORE_ACL_ERRORS*/, + nullptr, REPLACEFILE_IGNORE_MERGE_ERRORS | 4 /*REPLACEFILE_IGNORE_ACL_ERRORS*/, nullptr, nullptr) != 0; } Result File::createDirectoryInternal (const String& fileName) const { - return CreateDirectory (fileName.toWideCharPointer(), 0) ? Result::ok() - : WindowsFileHelpers::getResultForLastError(); + return CreateDirectory (fileName.toWideCharPointer(), nullptr) ? Result::ok() + : WindowsFileHelpers::getResultForLastError(); } //============================================================================== @@ -287,8 +287,8 @@ int64 juce_fileSetPosition (void* handle, int64 pos) void FileInputStream::openHandle() { auto h = CreateFile (file.getFullPathName().toWideCharPointer(), - GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, 0, - OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, 0); + GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, nullptr, + OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, nullptr); if (h != INVALID_HANDLE_VALUE) fileHandle = (void*) h; @@ -303,11 +303,11 @@ FileInputStream::~FileInputStream() size_t FileInputStream::readInternal (void* buffer, size_t numBytes) { - if (fileHandle != 0) + if (fileHandle != nullptr) { DWORD actualNum = 0; - if (! ReadFile ((HANDLE) fileHandle, buffer, (DWORD) numBytes, &actualNum, 0)) + if (! ReadFile ((HANDLE) fileHandle, buffer, (DWORD) numBytes, &actualNum, nullptr)) status = WindowsFileHelpers::getResultForLastError(); return (size_t) actualNum; @@ -320,8 +320,8 @@ size_t FileInputStream::readInternal (void* buffer, size_t numBytes) void FileOutputStream::openHandle() { auto h = CreateFile (file.getFullPathName().toWideCharPointer(), - GENERIC_WRITE, FILE_SHARE_READ, 0, - OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); + GENERIC_WRITE, FILE_SHARE_READ, nullptr, + OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); if (h != INVALID_HANDLE_VALUE) { @@ -350,7 +350,7 @@ ssize_t FileOutputStream::writeInternal (const void* bufferToWrite, size_t numBy DWORD actualNum = 0; if (fileHandle != nullptr) - if (! WriteFile ((HANDLE) fileHandle, bufferToWrite, (DWORD) numBytes, &actualNum, 0)) + if (! WriteFile ((HANDLE) fileHandle, bufferToWrite, (DWORD) numBytes, &actualNum, nullptr)) status = WindowsFileHelpers::getResultForLastError(); return (ssize_t) actualNum; @@ -398,18 +398,18 @@ void MemoryMappedFile::openInternal (const File& file, AccessMode mode, bool exc } auto h = CreateFile (file.getFullPathName().toWideCharPointer(), accessMode, - exclusive ? 0 : (FILE_SHARE_READ | FILE_SHARE_DELETE | (mode == readWrite ? FILE_SHARE_WRITE : 0)), 0, - createType, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, 0); + exclusive ? 0 : (FILE_SHARE_READ | FILE_SHARE_DELETE | (mode == readWrite ? FILE_SHARE_WRITE : 0)), nullptr, + createType, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, nullptr); if (h != INVALID_HANDLE_VALUE) { fileHandle = (void*) h; - auto mappingHandle = CreateFileMapping (h, 0, protect, + auto mappingHandle = CreateFileMapping (h, nullptr, protect, (DWORD) (range.getEnd() >> 32), - (DWORD) range.getEnd(), 0); + (DWORD) range.getEnd(), nullptr); - if (mappingHandle != 0) + if (mappingHandle != nullptr) { address = MapViewOfFile (mappingHandle, access, (DWORD) (range.getStart() >> 32), (DWORD) range.getStart(), (SIZE_T) range.getLength()); @@ -465,8 +465,8 @@ bool File::setFileTimesInternal (int64 modificationTime, int64 accessTime, int64 bool ok = false; auto h = CreateFile (fullPath.toWideCharPointer(), - GENERIC_WRITE, FILE_SHARE_READ, 0, - OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); + GENERIC_WRITE, FILE_SHARE_READ, nullptr, + OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); if (h != INVALID_HANDLE_VALUE) { @@ -512,7 +512,7 @@ String File::getVolumeLabel() const TCHAR dest[64]; if (! GetVolumeInformation (WindowsFileHelpers::getDriveFromPath (getFullPathName()).toWideCharPointer(), dest, - (DWORD) numElementsInArray (dest), 0, 0, 0, 0, 0)) + (DWORD) numElementsInArray (dest), nullptr, nullptr, nullptr, nullptr, 0)) dest[0] = 0; return dest; @@ -524,7 +524,7 @@ int File::getVolumeSerialNumber() const DWORD serialNum; if (! GetVolumeInformation (WindowsFileHelpers::getDriveFromPath (getFullPathName()).toWideCharPointer(), dest, - (DWORD) numElementsInArray (dest), &serialNum, 0, 0, 0, 0)) + (DWORD) numElementsInArray (dest), &serialNum, nullptr, nullptr, nullptr, 0)) return 0; return (int) serialNum; @@ -551,7 +551,7 @@ uint64 File::getFileIdentifier() const auto h = CreateFile (path.toWideCharPointer(), GENERIC_READ, FILE_SHARE_READ, nullptr, - OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0); + OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, nullptr); if (h != INVALID_HANDLE_VALUE) { @@ -640,7 +640,7 @@ File JUCE_CALLTYPE File::getSpecialLocation (const SpecialLocationType type) return WindowsFileHelpers::getModuleFileName ((HINSTANCE) Process::getCurrentModuleInstanceHandle()); case hostApplicationPath: - return WindowsFileHelpers::getModuleFileName (0); + return WindowsFileHelpers::getModuleFileName (nullptr); default: jassertfalse; // unknown type? @@ -715,7 +715,7 @@ static String readWindowsLnkFile (File lnkFile, bool wantsAbsolutePath) if (SUCCEEDED (shellLink.CoCreateInstance (CLSID_ShellLink)) && SUCCEEDED (shellLink.QueryInterface (persistFile)) && SUCCEEDED (persistFile->Load (lnkFile.getFullPathName().toWideCharPointer(), STGM_READ)) - && (! wantsAbsolutePath || SUCCEEDED (shellLink->Resolve (0, SLR_ANY_MATCH | SLR_NO_UI)))) + && (! wantsAbsolutePath || SUCCEEDED (shellLink->Resolve (nullptr, SLR_ANY_MATCH | SLR_NO_UI)))) { WIN32_FIND_DATA winFindData; WCHAR resolvedPath[MAX_PATH]; @@ -741,7 +741,7 @@ static String readWindowsShortcutOrLink (const File& shortcut, bool wantsAbsolut HANDLE h = CreateFile (shortcut.getFullPathName().toWideCharPointer(), GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OPEN_REPARSE_POINT, - 0); + nullptr); if (h != INVALID_HANDLE_VALUE) { @@ -809,7 +809,7 @@ static String readWindowsShortcutOrLink (const File& shortcut, bool wantsAbsolut { HANDLE h = CreateFile (shortcut.getFullPathName().toWideCharPointer(), GENERIC_READ, FILE_SHARE_READ, nullptr, - OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0); + OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, nullptr); if (h != INVALID_HANDLE_VALUE) { @@ -861,7 +861,7 @@ bool File::createShortcut (const String& description, const File& linkFileToCrea ComSmartPtr shellLink; ComSmartPtr persistFile; - CoInitialize (0); + CoInitialize (nullptr); return SUCCEEDED (shellLink.CoCreateInstance (CLSID_ShellLink)) && SUCCEEDED (shellLink->SetPath (getFullPathName().toWideCharPointer())) @@ -945,8 +945,8 @@ bool DirectoryIterator::NativeIterator::next (String& filenameFound, //============================================================================== bool JUCE_CALLTYPE Process::openDocument (const String& fileName, const String& parameters) { - HINSTANCE hInstance = ShellExecute (0, 0, fileName.toWideCharPointer(), - parameters.toWideCharPointer(), 0, SW_SHOWDEFAULT); + HINSTANCE hInstance = ShellExecute (nullptr, nullptr, fileName.toWideCharPointer(), + parameters.toWideCharPointer(), nullptr, SW_SHOWDEFAULT); return hInstance > (HINSTANCE) 32; } @@ -975,14 +975,14 @@ public: Pimpl (const String& pipeName, const bool createPipe, bool mustNotExist) : filename ("\\\\.\\pipe\\" + File::createLegalFileName (pipeName)), pipeH (INVALID_HANDLE_VALUE), - cancelEvent (CreateEvent (0, FALSE, FALSE, 0)), + cancelEvent (CreateEvent (nullptr, FALSE, FALSE, nullptr)), connected (false), ownsPipe (createPipe), shouldStop (false) { if (createPipe) { pipeH = CreateNamedPipe (filename.toWideCharPointer(), PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED, 0, - PIPE_UNLIMITED_INSTANCES, 4096, 4096, 0, 0); + PIPE_UNLIMITED_INSTANCES, 4096, 4096, 0, nullptr); if (mustNotExist && GetLastError() == ERROR_ALREADY_EXISTS) closePipeHandle(); @@ -1011,8 +1011,8 @@ public: if (pipeH == INVALID_HANDLE_VALUE) pipeH = CreateFile (filename.toWideCharPointer(), - GENERIC_READ | GENERIC_WRITE, 0, 0, - OPEN_EXISTING, FILE_FLAG_OVERLAPPED, 0); + GENERIC_READ | GENERIC_WRITE, 0, nullptr, + OPEN_EXISTING, FILE_FLAG_OVERLAPPED, nullptr); } if (pipeH != INVALID_HANDLE_VALUE) @@ -1136,7 +1136,7 @@ private: OverlappedEvent() { zerostruct (over); - over.hEvent = CreateEvent (0, TRUE, FALSE, 0); + over.hEvent = CreateEvent (nullptr, TRUE, FALSE, nullptr); } ~OverlappedEvent() @@ -1154,7 +1154,7 @@ private: HANDLE handles[] = { over.over.hEvent, cancelEvent }; DWORD waitResult = WaitForMultipleObjects (2, handles, FALSE, - timeOutMilliseconds >= 0 ? timeOutMilliseconds + timeOutMilliseconds >= 0 ? (DWORD) timeOutMilliseconds : INFINITE); if (waitResult == WAIT_OBJECT_0) diff --git a/modules/juce_core/native/juce_win32_Network.cpp b/modules/juce_core/native/juce_win32_Network.cpp index 9eb92511f1..c0289fc2fc 100644 --- a/modules/juce_core/native/juce_win32_Network.cpp +++ b/modules/juce_core/native/juce_win32_Network.cpp @@ -90,7 +90,7 @@ public: { HeapBlock buffer (bufferSizeBytes); - if (HttpQueryInfo (request, HTTP_QUERY_RAW_HEADERS_CRLF, buffer.getData(), &bufferSizeBytes, 0)) + if (HttpQueryInfo (request, HTTP_QUERY_RAW_HEADERS_CRLF, buffer.getData(), &bufferSizeBytes, nullptr)) { StringArray headersArray; headersArray.addLines (String (reinterpret_cast (buffer.getData()))); @@ -116,7 +116,7 @@ public: DWORD status = 0; DWORD statusSize = sizeof (status); - if (HttpQueryInfo (request, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &status, &statusSize, 0)) + if (HttpQueryInfo (request, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &status, &statusSize, nullptr)) { statusCode = (int) status; @@ -151,10 +151,10 @@ public: break; } - return (request != 0); + return (request != nullptr); } - bool isError() const { return request == 0; } + bool isError() const { return request == nullptr; } bool isExhausted() { return finished; } int64 getPosition() { return position; } @@ -207,7 +207,7 @@ public: if (wantedPos != position) { finished = false; - position = (int64) InternetSetFilePointer (request, (LONG) wantedPos, 0, FILE_BEGIN, 0); + position = (int64) InternetSetFilePointer (request, (LONG) wantedPos, nullptr, FILE_BEGIN, 0); if (position == wantedPos) return true; @@ -232,7 +232,7 @@ private: //============================================================================== WebInputStream& owner; const URL url; - HINTERNET connection = 0, request = 0; + HINTERNET connection = nullptr, request = nullptr; String headers; MemoryBlock postData; int64 position = 0; @@ -249,25 +249,25 @@ private: { HINTERNET requestCopy = request; - request = 0; + request = nullptr; - if (requestCopy != 0) + if (requestCopy != nullptr) InternetCloseHandle (requestCopy); - if (connection != 0) + if (connection != nullptr) { InternetCloseHandle (connection); - connection = 0; + connection = nullptr; } } void createConnection (const String& address, WebInputStream::Listener* listener) { - static HINTERNET sessionHandle = InternetOpen (_T("juce"), INTERNET_OPEN_TYPE_PRECONFIG, 0, 0, 0); + static HINTERNET sessionHandle = InternetOpen (_T("juce"), INTERNET_OPEN_TYPE_PRECONFIG, nullptr, nullptr, 0); closeConnection(); - if (sessionHandle != 0) + if (sessionHandle != nullptr) { // break up the url.. const int fileNumChars = 65536; @@ -319,7 +319,7 @@ private: { const ScopedLock lock (createConnectionLock); - connection = hasBeenCancelled ? 0 + connection = hasBeenCancelled ? nullptr : InternetConnect (sessionHandle, uc.lpszHostName, uc.nPort, uc.lpszUserName, uc.lpszPassword, @@ -328,7 +328,7 @@ private: 0, 0); } - if (connection != 0) + if (connection != nullptr) { if (isFtp) request = FtpOpenFile (connection, uc.lpszUrlPath, GENERIC_READ, @@ -345,7 +345,7 @@ private: void sendHTTPRequest (INTERNET_BUFFERS& buffers, WebInputStream::Listener* listener) { - if (! HttpSendRequestEx (request, &buffers, 0, HSR_INITIATE, 0)) + if (! HttpSendRequestEx (request, &buffers, nullptr, HSR_INITIATE, 0)) return; int totalBytesSent = 0; @@ -362,7 +362,7 @@ private: return; } - totalBytesSent += bytesSent; + totalBytesSent += (int) bytesSent; if (listener != nullptr && ! listener->postDataSendProgress (owner, totalBytesSent, (int) postData.getSize())) @@ -386,12 +386,12 @@ private: { const ScopedLock lock (createConnectionLock); - request = hasBeenCancelled ? 0 + request = hasBeenCancelled ? nullptr : HttpOpenRequest (connection, httpRequestCmd.toWideCharPointer(), - uc.lpszUrlPath, 0, 0, mimeTypes, flags, 0); + uc.lpszUrlPath, nullptr, nullptr, mimeTypes, flags, 0); } - if (request != 0) + if (request != nullptr) { INTERNET_BUFFERS buffers = {}; buffers.dwStructSize = sizeof (INTERNET_BUFFERS); @@ -403,7 +403,7 @@ private: { sendHTTPRequest (buffers, listener); - if (HttpEndRequest (request, 0, 0, 0)) + if (HttpEndRequest (request, nullptr, 0, 0)) return true; return false; @@ -440,10 +440,10 @@ struct GetAdaptersAddressesHelper adaptersAddresses.malloc (1); ULONG len = sizeof (IP_ADAPTER_ADDRESSES); - if (getAdaptersAddresses (AF_UNSPEC, GAA_FLAG_INCLUDE_PREFIX, NULL, adaptersAddresses, &len) == ERROR_BUFFER_OVERFLOW) + if (getAdaptersAddresses (AF_UNSPEC, GAA_FLAG_INCLUDE_PREFIX, nullptr, adaptersAddresses, &len) == ERROR_BUFFER_OVERFLOW) adaptersAddresses.malloc (len, 1); - return getAdaptersAddresses (AF_UNSPEC, GAA_FLAG_INCLUDE_PREFIX, NULL, adaptersAddresses, &len) == NO_ERROR; + return getAdaptersAddresses (AF_UNSPEC, GAA_FLAG_INCLUDE_PREFIX, nullptr, adaptersAddresses, &len) == NO_ERROR; } HeapBlock adaptersAddresses; @@ -476,7 +476,7 @@ namespace MACAddressHelpers DynamicLibrary dll ("netapi32.dll"); JUCE_LOAD_WINAPI_FUNCTION (dll, Netbios, NetbiosCall, UCHAR, (PNCB)) - if (NetbiosCall != 0) + if (NetbiosCall != nullptr) { LANA_ENUM enums = {}; diff --git a/modules/juce_core/native/juce_win32_Registry.cpp b/modules/juce_core/native/juce_win32_Registry.cpp index 03ddba1055..c0d08630bb 100644 --- a/modules/juce_core/native/juce_win32_Registry.cpp +++ b/modules/juce_core/native/juce_win32_Registry.cpp @@ -40,8 +40,8 @@ struct RegistryKeyWrapper DWORD result; if (createForWriting) - RegCreateKeyEx (rootKey, wideCharName, 0, 0, REG_OPTION_NON_VOLATILE, - KEY_WRITE | KEY_QUERY_VALUE | wow64Flags, 0, &key, &result); + RegCreateKeyEx (rootKey, wideCharName, 0, nullptr, REG_OPTION_NON_VOLATILE, + KEY_WRITE | KEY_QUERY_VALUE | wow64Flags, nullptr, &key, &result); else RegOpenKeyEx (rootKey, wideCharName, 0, KEY_READ | wow64Flags, &key); } @@ -65,7 +65,7 @@ struct RegistryKeyWrapper if (name.startsWithIgnoreCase ("HKU\\")) return HKEY_USERS; jassertfalse; // The name starts with an unknown root key (or maybe an old Win9x type) - return 0; + return nullptr; } static bool setValue (const String& regValuePath, const DWORD type, @@ -90,7 +90,7 @@ struct RegistryKeyWrapper result.setSize (bufferSize, false); DWORD type = REG_NONE; - auto err = RegQueryValueEx (key.key, key.wideCharValueName, 0, &type, + auto err = RegQueryValueEx (key.key, key.wideCharValueName, nullptr, &type, (LPBYTE) result.getData(), &bufferSize); if (err == ERROR_SUCCESS) @@ -138,7 +138,7 @@ struct RegistryKeyWrapper DWORD type = 0; auto result = RegQueryValueEx (key.key, key.wideCharValueName, - 0, &type, buffer, &bufferSize); + nullptr, &type, buffer, &bufferSize); return result == ERROR_SUCCESS || result == ERROR_MORE_DATA; } diff --git a/modules/juce_core/native/juce_win32_SystemStats.cpp b/modules/juce_core/native/juce_win32_SystemStats.cpp index dc81aa7644..83f5dc6210 100644 --- a/modules/juce_core/native/juce_win32_SystemStats.cpp +++ b/modules/juce_core/native/juce_win32_SystemStats.cpp @@ -44,7 +44,8 @@ void Logger::outputDebugString (const String& text) #if JUCE_MINGW || JUCE_CLANG static void callCPUID (int result[4], uint32 type) { - uint32 la = result[0], lb = result[1], lc = result[2], ld = result[3]; + uint32 la = (uint32) result[0], lb = (uint32) result[1], + lc = (uint32) result[2], ld = (uint32) result[3]; asm ("mov %%ebx, %%esi \n\t" "cpuid \n\t" @@ -55,7 +56,8 @@ static void callCPUID (int result[4], uint32 type) #endif ); - result[0] = la; result[1] = lb; result[2] = lc; result[3] = ld; + result[0] = (int) la; result[1] = (int) lb; + result[2] = (int) lc; result[3] = (int) ld; } #else static void callCPUID (int result[4], int infoType) @@ -155,17 +157,17 @@ void CPUInformation::initialise() noexcept callCPUID (info, 7); - hasAVX2 = (info[1] & (1 << 5)) != 0; - hasAVX512F = (info[1] & (1u << 16)) != 0; - hasAVX512DQ = (info[1] & (1u << 17)) != 0; - hasAVX512IFMA = (info[1] & (1u << 21)) != 0; - hasAVX512PF = (info[1] & (1u << 26)) != 0; - hasAVX512ER = (info[1] & (1u << 27)) != 0; - hasAVX512CD = (info[1] & (1u << 28)) != 0; - hasAVX512BW = (info[1] & (1u << 30)) != 0; - hasAVX512VL = (info[1] & (1u << 31)) != 0; - hasAVX512VBMI = (info[2] & (1u << 1)) != 0; - hasAVX512VPOPCNTDQ = (info[2] & (1u << 14)) != 0; + hasAVX2 = ((unsigned int) info[1] & (1 << 5)) != 0; + hasAVX512F = ((unsigned int) info[1] & (1u << 16)) != 0; + hasAVX512DQ = ((unsigned int) info[1] & (1u << 17)) != 0; + hasAVX512IFMA = ((unsigned int) info[1] & (1u << 21)) != 0; + hasAVX512PF = ((unsigned int) info[1] & (1u << 26)) != 0; + hasAVX512ER = ((unsigned int) info[1] & (1u << 27)) != 0; + hasAVX512CD = ((unsigned int) info[1] & (1u << 28)) != 0; + hasAVX512BW = ((unsigned int) info[1] & (1u << 30)) != 0; + hasAVX512VL = ((unsigned int) info[1] & (1u << 31)) != 0; + hasAVX512VBMI = ((unsigned int) info[2] & (1u << 1)) != 0; + hasAVX512VPOPCNTDQ = ((unsigned int) info[2] & (1u << 14)) != 0; SYSTEM_INFO systemInfo; GetNativeSystemInfo (&systemInfo); @@ -274,6 +276,26 @@ String SystemStats::getOperatingSystemName() case WinVista: name = "Windows Vista"; break; case WinXP: name = "Windows XP"; break; case Win2000: name = "Windows 2000"; break; + + case MacOSX: JUCE_FALLTHROUGH + case Windows: JUCE_FALLTHROUGH + case Linux: JUCE_FALLTHROUGH + case Android: JUCE_FALLTHROUGH + case iOS: JUCE_FALLTHROUGH + + case MacOSX_10_4: JUCE_FALLTHROUGH + case MacOSX_10_5: JUCE_FALLTHROUGH + case MacOSX_10_6: JUCE_FALLTHROUGH + case MacOSX_10_7: JUCE_FALLTHROUGH + case MacOSX_10_8: JUCE_FALLTHROUGH + case MacOSX_10_9: JUCE_FALLTHROUGH + case MacOSX_10_10: JUCE_FALLTHROUGH + case MacOSX_10_11: JUCE_FALLTHROUGH + case MacOSX_10_12: JUCE_FALLTHROUGH + case MacOSX_10_13: JUCE_FALLTHROUGH + case MacOSX_10_14: JUCE_FALLTHROUGH + + case UnknownOS: JUCE_FALLTHROUGH default: jassertfalse; break; // !! new type of OS? } diff --git a/modules/juce_core/native/juce_win32_Threads.cpp b/modules/juce_core/native/juce_win32_Threads.cpp index 77acd5a490..dbe0c6b5da 100644 --- a/modules/juce_core/native/juce_win32_Threads.cpp +++ b/modules/juce_core/native/juce_win32_Threads.cpp @@ -23,12 +23,12 @@ namespace juce { -HWND juce_messageWindowHandle = 0; // (this is used by other parts of the codebase) +HWND juce_messageWindowHandle = nullptr; // (this is used by other parts of the codebase) void* getUser32Function (const char* functionName) { HMODULE module = GetModuleHandleA ("user32.dll"); - jassert (module != 0); + jassert (module != nullptr); return (void*) GetProcAddress (module, functionName); } @@ -53,8 +53,8 @@ void JUCE_API juce_threadEntryPoint (void*); static unsigned int __stdcall threadEntryProc (void* userData) { - if (juce_messageWindowHandle != 0) - AttachThreadInput (GetWindowThreadProcessId (juce_messageWindowHandle, 0), + if (juce_messageWindowHandle != nullptr) + AttachThreadInput (GetWindowThreadProcessId (juce_messageWindowHandle, nullptr), GetCurrentThreadId(), TRUE); juce_threadEntryPoint (userData); @@ -66,7 +66,7 @@ static unsigned int __stdcall threadEntryProc (void* userData) void Thread::launchThread() { unsigned int newThreadId; - threadHandle = (void*) _beginthreadex (0, (unsigned int) threadStackSize, + threadHandle = (void*) _beginthreadex (nullptr, (unsigned int) threadStackSize, &threadEntryProc, this, 0, &newThreadId); threadId = (ThreadID) (pointer_sized_int) newThreadId; } @@ -74,13 +74,13 @@ void Thread::launchThread() void Thread::closeThreadHandle() { CloseHandle ((HANDLE) threadHandle.get()); - threadId = 0; - threadHandle = 0; + threadId = nullptr; + threadHandle = nullptr; } void Thread::killThread() { - if (threadHandle.get() != 0) + if (threadHandle.get() != nullptr) { #if JUCE_DEBUG OutputDebugStringA ("** Warning - Forced thread termination **\n"); @@ -132,7 +132,7 @@ bool Thread::setThreadPriority (void* handle, int priority) else if (priority < 9) pri = THREAD_PRIORITY_ABOVE_NORMAL; else if (priority < 10) pri = THREAD_PRIORITY_HIGHEST; - if (handle == 0) + if (handle == nullptr) handle = GetCurrentThread(); return SetThreadPriority (handle, pri) != FALSE; @@ -158,7 +158,7 @@ struct SleepEvent ~SleepEvent() noexcept { CloseHandle (handle); - handle = 0; + handle = nullptr; } HANDLE handle; @@ -170,7 +170,7 @@ void JUCE_CALLTYPE Thread::sleep (const int millisecs) { jassert (millisecs >= 0); - if (millisecs >= 10 || sleepEvent.handle == 0) + if (millisecs >= 10 || sleepEvent.handle == nullptr) Sleep ((DWORD) millisecs); else // unlike Sleep() this is guaranteed to return to the current thread after @@ -260,7 +260,7 @@ void JUCE_CALLTYPE Process::terminate() bool juce_isRunningInWine() { HMODULE ntdll = GetModuleHandleA ("ntdll"); - return ntdll != 0 && GetProcAddress (ntdll, "wine_get_version") != nullptr; + return ntdll != nullptr && GetProcAddress (ntdll, "wine_get_version") != nullptr; } //============================================================================== @@ -292,18 +292,18 @@ class InterProcessLock::Pimpl { public: Pimpl (String name, const int timeOutMillisecs) - : handle (0), refCount (1) + : handle (nullptr), refCount (1) { name = name.replaceCharacter ('\\', '/'); - handle = CreateMutexW (0, TRUE, ("Global\\" + name).toWideCharPointer()); + handle = CreateMutexW (nullptr, TRUE, ("Global\\" + name).toWideCharPointer()); // Not 100% sure why a global mutex sometimes can't be allocated, but if it fails, fall back to // a local one. (A local one also sometimes fails on other machines so neither type appears to be // universally reliable) - if (handle == 0) - handle = CreateMutexW (0, TRUE, ("Local\\" + name).toWideCharPointer()); + if (handle == nullptr) + handle = CreateMutexW (nullptr, TRUE, ("Local\\" + name).toWideCharPointer()); - if (handle != 0 && GetLastError() == ERROR_ALREADY_EXISTS) + if (handle != nullptr && GetLastError() == ERROR_ALREADY_EXISTS) { if (timeOutMillisecs == 0) { @@ -311,7 +311,7 @@ public: return; } - switch (WaitForSingleObject (handle, timeOutMillisecs < 0 ? INFINITE : timeOutMillisecs)) + switch (WaitForSingleObject (handle, timeOutMillisecs < 0 ? INFINITE : (DWORD) timeOutMillisecs)) { case WAIT_OBJECT_0: case WAIT_ABANDONED: @@ -332,11 +332,11 @@ public: void close() { - if (handle != 0) + if (handle != nullptr) { ReleaseMutex (handle); CloseHandle (handle); - handle = 0; + handle = nullptr; } } @@ -361,7 +361,7 @@ bool InterProcessLock::enter (const int timeOutMillisecs) { pimpl.reset (new Pimpl (name, timeOutMillisecs)); - if (pimpl->handle == 0) + if (pimpl->handle == nullptr) pimpl.reset(); } else @@ -388,7 +388,7 @@ class ChildProcess::ActiveProcess { public: ActiveProcess (const String& command, int streamFlags) - : ok (false), readPipe (0), writePipe (0) + : ok (false), readPipe (nullptr), writePipe (nullptr) { SECURITY_ATTRIBUTES securityAtts = {}; securityAtts.nLength = sizeof (securityAtts); @@ -400,8 +400,8 @@ public: STARTUPINFOW startupInfo = {}; startupInfo.cb = sizeof (startupInfo); - startupInfo.hStdOutput = (streamFlags & wantStdOut) != 0 ? writePipe : 0; - startupInfo.hStdError = (streamFlags & wantStdErr) != 0 ? writePipe : 0; + startupInfo.hStdOutput = (streamFlags & wantStdOut) != 0 ? writePipe : nullptr; + startupInfo.hStdError = (streamFlags & wantStdErr) != 0 ? writePipe : nullptr; startupInfo.dwFlags = STARTF_USESTDHANDLES; ok = CreateProcess (nullptr, const_cast (command.toWideCharPointer()), @@ -418,10 +418,10 @@ public: CloseHandle (processInfo.hProcess); } - if (readPipe != 0) + if (readPipe != nullptr) CloseHandle (readPipe); - if (writePipe != 0) + if (writePipe != nullptr) CloseHandle (writePipe); } @@ -453,12 +453,12 @@ public: else { DWORD numRead = 0; - if (! ReadFile ((HANDLE) readPipe, dest, numToDo, &numRead, nullptr)) + if (! ReadFile ((HANDLE) readPipe, dest, (DWORD) numToDo, &numRead, nullptr)) break; - total += numRead; + total += (int) numRead; dest = addBytesToPointer (dest, numRead); - numNeeded -= numRead; + numNeeded -= (int) numRead; } } @@ -539,7 +539,7 @@ struct HighResolutionTimer::Pimpl { const int actualPeriod = jlimit ((int) tc.wPeriodMin, (int) tc.wPeriodMax, newPeriod); - timerID = timeSetEvent (actualPeriod, tc.wPeriodMin, callbackFunction, (DWORD_PTR) this, + timerID = timeSetEvent ((UINT) actualPeriod, tc.wPeriodMin, callbackFunction, (DWORD_PTR) this, TIME_PERIODIC | TIME_CALLBACK_FUNCTION | 0x100 /*TIME_KILL_SYNCHRONOUS*/); } } diff --git a/modules/juce_core/network/juce_Socket.cpp b/modules/juce_core/network/juce_Socket.cpp index 4f6326391b..5c5530ce77 100644 --- a/modules/juce_core/network/juce_Socket.cpp +++ b/modules/juce_core/network/juce_Socket.cpp @@ -94,7 +94,7 @@ namespace SocketHelpers static void closeSocket (std::atomic& handle, CriticalSection& readLock, bool isListener, int portNumber, std::atomic& connected) noexcept { - const SocketHandle h = handle.load(); + const auto h = (SocketHandle) handle.load(); handle = -1; #if JUCE_WINDOWS @@ -187,7 +187,7 @@ namespace SocketHelpers { #if JUCE_WINDOWS u_long nonBlocking = shouldBlock ? 0 : (u_long) 1; - return ioctlsocket (handle, FIONBIO, &nonBlocking) == 0; + return ioctlsocket (handle, (long) FIONBIO, &nonBlocking) == 0; #else int socketFlags = fcntl (handle, F_GETFL, 0); @@ -282,9 +282,9 @@ namespace SocketHelpers auto hasErrorOccurred = [&handle] () -> bool { - auto h = handle.load(); + auto h = (SocketHandle) handle.load(); - if (static_cast (h) == invalidSocket) + if (h == invalidSocket) return true; int opt; @@ -315,9 +315,9 @@ namespace SocketHelpers fd_set rset, wset; FD_ZERO (&rset); - FD_SET (static_cast (h), &rset); + FD_SET ((SOCKET) h, &rset); FD_ZERO (&wset); - FD_SET (static_cast (h), &wset); + FD_SET ((SOCKET) h, &wset); fd_set* prset = forReading ? &rset : nullptr; fd_set* pwset = forReading ? nullptr : &wset; @@ -418,8 +418,9 @@ namespace SocketHelpers if (success) { - setSocketBlockingState (handle, true); - resetSocketOptions (handle, false, false); + auto h = (SocketHandle) handle.load(); + setSocketBlockingState (h, true); + resetSocketOptions (h, false, false); } } @@ -428,7 +429,7 @@ namespace SocketHelpers static void makeReusable (int handle) noexcept { - setOption (handle, SO_REUSEADDR, (int) 1); + setOption ((SocketHandle) handle, SO_REUSEADDR, (int) 1); } static bool multicast (int handle, const String& multicastIPAddress, @@ -443,7 +444,7 @@ namespace SocketHelpers if (interfaceIPAddress.isNotEmpty()) mreq.imr_interface.s_addr = inet_addr (interfaceIPAddress.toRawUTF8()); - return setsockopt (handle, IPPROTO_IP, + return setsockopt ((SocketHandle) handle, IPPROTO_IP, join ? IP_ADD_MEMBERSHIP : IP_DROP_MEMBERSHIP, (const char*) &mreq, sizeof (mreq)) == 0; @@ -465,7 +466,7 @@ StreamingSocket::StreamingSocket (const String& host, int portNum, int h) jassert (SocketHelpers::isValidPortNumber (portNum)); SocketHelpers::initSockets(); - SocketHelpers::resetSocketOptions (h, false, false); + SocketHelpers::resetSocketOptions ((SocketHandle) h, false, false); } StreamingSocket::~StreamingSocket() @@ -476,7 +477,7 @@ StreamingSocket::~StreamingSocket() //============================================================================== int StreamingSocket::read (void* destBuffer, int maxBytesToRead, bool shouldBlock) { - return (connected && ! isListener) ? SocketHelpers::readSocket (handle, destBuffer, maxBytesToRead, + return (connected && ! isListener) ? SocketHelpers::readSocket ((SocketHandle) handle.load(), destBuffer,maxBytesToRead, connected, shouldBlock, readLock) : -1; } @@ -486,7 +487,7 @@ int StreamingSocket::write (const void* sourceBuffer, int numBytesToWrite) if (isListener || ! connected) return -1; - return (int) ::send (handle, (const char*) sourceBuffer, (juce_recvsend_size_t) numBytesToWrite, 0); + return (int) ::send ((SocketHandle) handle.load(), (const char*) sourceBuffer, (juce_recvsend_size_t) numBytesToWrite, 0); } //============================================================================== @@ -506,12 +507,12 @@ bool StreamingSocket::bindToPort (int port, const String& addr) { jassert (SocketHelpers::isValidPortNumber (port)); - return SocketHelpers::bindSocket (handle, port, addr); + return SocketHelpers::bindSocket ((SocketHandle) handle.load(), port, addr); } int StreamingSocket::getBoundPort() const noexcept { - return SocketHelpers::getBoundPort (handle); + return SocketHelpers::getBoundPort ((SocketHandle) handle.load()); } bool StreamingSocket::connect (const String& remoteHostName, int remotePortNumber, int timeOutMillisecs) @@ -538,7 +539,7 @@ bool StreamingSocket::connect (const String& remoteHostName, int remotePortNumbe if (! connected) return false; - if (! SocketHelpers::resetSocketOptions (handle, false, false)) + if (! SocketHelpers::resetSocketOptions ((SocketHandle) handle.load(), false, false)) { close(); return false; @@ -579,8 +580,8 @@ bool StreamingSocket::createListener (int newPortNumber, const String& localHost SocketHelpers::makeReusable (handle); #endif - if (SocketHelpers::bindSocket (handle, portNumber, localHostName) - && listen (handle, SOMAXCONN) >= 0) + if (SocketHelpers::bindSocket ((SocketHandle) handle.load(), portNumber, localHostName) + && listen ((SocketHandle) handle.load(), SOMAXCONN) >= 0) { connected = true; return true; @@ -600,7 +601,7 @@ StreamingSocket* StreamingSocket::waitForNextConnection() const { struct sockaddr_storage address; juce_socklen_t len = sizeof (address); - auto newSocket = (int) accept (handle, (struct sockaddr*) &address, &len); + auto newSocket = (int) accept ((SocketHandle) handle.load(), (struct sockaddr*) &address, &len); if (newSocket >= 0 && connected) return new StreamingSocket (inet_ntoa (((struct sockaddr_in*) &address)->sin_addr), @@ -615,7 +616,7 @@ bool StreamingSocket::isLocal() const noexcept if (! isConnected()) return false; - IPAddress currentIP (SocketHelpers::getConnectedAddress (handle)); + IPAddress currentIP (SocketHelpers::getConnectedAddress ((SocketHandle) handle.load())); for (auto& a : IPAddress::getAllAddresses()) if (a == currentIP) @@ -635,7 +636,7 @@ DatagramSocket::DatagramSocket (bool canBroadcast) if (handle >= 0) { - SocketHelpers::resetSocketOptions (handle, true, canBroadcast); + SocketHelpers::resetSocketOptions ((SocketHandle) handle.load(), true, canBroadcast); SocketHelpers::makeReusable (handle); } } @@ -674,7 +675,7 @@ bool DatagramSocket::bindToPort (int port, const String& addr) if (handle < 0) return false; - if (SocketHelpers::bindSocket (handle, port, addr)) + if (SocketHelpers::bindSocket ((SocketHandle) handle.load(), port, addr)) { isBound = true; lastBindAddress = addr; @@ -686,7 +687,7 @@ bool DatagramSocket::bindToPort (int port, const String& addr) int DatagramSocket::getBoundPort() const noexcept { - return (handle >= 0 && isBound) ? SocketHelpers::getBoundPort (handle) : -1; + return (handle >= 0 && isBound) ? SocketHelpers::getBoundPort ((SocketHandle) handle.load()) : -1; } //============================================================================== @@ -704,7 +705,7 @@ int DatagramSocket::read (void* destBuffer, int maxBytesToRead, bool shouldBlock return -1; std::atomic connected { true }; - return SocketHelpers::readSocket (handle, destBuffer, maxBytesToRead, + return SocketHelpers::readSocket ((SocketHandle) handle.load(), destBuffer, maxBytesToRead, connected, shouldBlock, readLock); } @@ -714,7 +715,7 @@ int DatagramSocket::read (void* destBuffer, int maxBytesToRead, bool shouldBlock return -1; std::atomic connected { true }; - return SocketHelpers::readSocket (handle, destBuffer, maxBytesToRead, connected, + return SocketHelpers::readSocket ((SocketHandle) handle.load(), destBuffer, maxBytesToRead, connected, shouldBlock, readLock, &senderIPAddress, &senderPort); } @@ -741,7 +742,7 @@ int DatagramSocket::write (const String& remoteHostname, int remotePortNumber, lastServerPort = remotePortNumber; } - return (int) ::sendto (handle, (const char*) sourceBuffer, + return (int) ::sendto ((SocketHandle) handle.load(), (const char*) sourceBuffer, (juce_recvsend_size_t) numBytesToWrite, 0, info->ai_addr, (socklen_t) info->ai_addrlen); } @@ -767,7 +768,7 @@ bool DatagramSocket::setMulticastLoopbackEnabled (bool enable) if (handle < 0 || ! isBound) return false; - return SocketHelpers::setOption (handle, IPPROTO_IP, IP_MULTICAST_LOOP, enable); + return SocketHelpers::setOption ((SocketHandle) handle.load(), IPPROTO_IP, IP_MULTICAST_LOOP, enable); } bool DatagramSocket::setEnablePortReuse (bool enabled) @@ -776,7 +777,7 @@ bool DatagramSocket::setEnablePortReuse (bool enabled) ignoreUnused (enabled); #else if (handle >= 0) - return SocketHelpers::setOption (handle, + return SocketHelpers::setOption ((SocketHandle) handle.load(), #if JUCE_WINDOWS || JUCE_LINUX SO_REUSEADDR, // port re-use is implied by addr re-use on these platforms #else diff --git a/modules/juce_core/text/juce_String.cpp b/modules/juce_core/text/juce_String.cpp index 4d1ff2aa04..43047eba28 100644 --- a/modules/juce_core/text/juce_String.cpp +++ b/modules/juce_core/text/juce_String.cpp @@ -1837,6 +1837,10 @@ String String::formattedRaw (const char* pf, ...) va_list args; va_start (args, pf); + #if JUCE_WINDOWS + JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wdeprecated-declarations") + #endif + #if JUCE_ANDROID HeapBlock temp (bufferSize); int num = (int) vsnprintf (temp.get(), bufferSize - 1, pf, args); @@ -1847,17 +1851,16 @@ String String::formattedRaw (const char* pf, ...) HeapBlock temp (bufferSize); const int num = (int) #if JUCE_WINDOWS - JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wdeprecated-declarations") _vsnwprintf #else vswprintf #endif (temp.get(), bufferSize - 1, wideCharVersion.toWideCharPointer(), args); + #endif #if JUCE_WINDOWS - JUCE_END_IGNORE_WARNINGS_GCC_LIKE + JUCE_END_IGNORE_WARNINGS_GCC_LIKE #endif - #endif va_end (args); if (num > 0) @@ -1894,7 +1897,7 @@ int String::getTrailingIntValue() const noexcept break; } - n += static_cast (mult) * (*t - '0'); + n += (int) (((juce_wchar) mult) * (*t - '0')); mult *= 10; } diff --git a/modules/juce_events/native/juce_win32_HiddenMessageWindow.h b/modules/juce_events/native/juce_win32_HiddenMessageWindow.h index 970a9b433f..6f8d9b8b2b 100644 --- a/modules/juce_events/native/juce_win32_HiddenMessageWindow.h +++ b/modules/juce_events/native/juce_win32_HiddenMessageWindow.h @@ -45,14 +45,15 @@ public: jassert (atom != 0); hwnd = CreateWindow (getClassNameFromAtom(), messageWindowName, - 0, 0, 0, 0, 0, 0, 0, moduleHandle, 0); - jassert (hwnd != 0); + 0, 0, 0, 0, 0, + nullptr, nullptr, moduleHandle, nullptr); + jassert (hwnd != nullptr); } ~HiddenMessageWindow() { DestroyWindow (hwnd); - UnregisterClass (getClassNameFromAtom(), 0); + UnregisterClass (getClassNameFromAtom(), nullptr); } inline HWND getHWND() const noexcept { return hwnd; } diff --git a/modules/juce_events/native/juce_win32_Messaging.cpp b/modules/juce_events/native/juce_win32_Messaging.cpp index 4bb006dc62..baec15552f 100644 --- a/modules/juce_events/native/juce_win32_Messaging.cpp +++ b/modules/juce_events/native/juce_win32_Messaging.cpp @@ -51,7 +51,7 @@ public: ~InternalMessageQueue() { - juce_messageWindowHandle = 0; + juce_messageWindowHandle = nullptr; clearSingletonInstance(); } @@ -69,7 +69,7 @@ public: { COPYDATASTRUCT data; data.dwData = broadcastMessageMagicNumber; - data.cbData = (localCopy.length() + 1) * sizeof (CharPointer_UTF32::CharType); + data.cbData = ((size_t) localCopy.length() + 1) * sizeof (CharPointer_UTF32::CharType); data.lpData = (void*) localCopy.toUTF32().getAddress(); DWORD_PTR result; @@ -109,10 +109,10 @@ public: { MSG m; - if (returnIfNoPendingMessages && ! PeekMessage (&m, (HWND) 0, 0, 0, PM_NOREMOVE)) + if (returnIfNoPendingMessages && ! PeekMessage (&m, nullptr, 0, 0, PM_NOREMOVE)) return false; - if (GetMessage (&m, (HWND) 0, 0, 0) >= 0) + if (GetMessage (&m, nullptr, 0, 0) >= 0) { #if JUCE_MODULE_AVAILABLE_juce_gui_extra if (juce_offerEventToActiveXControl (m) != S_FALSE) @@ -137,7 +137,7 @@ public: // currently on a juce window, pass the kb focus over.. auto currentFocus = GetFocus(); - if (currentFocus == 0 || JuceWindowIdentifier::isJUCEWindow (currentFocus)) + if (currentFocus == nullptr || JuceWindowIdentifier::isJUCEWindow (currentFocus)) SetFocus (m.hwnd); } @@ -288,7 +288,7 @@ void MessageManager::broadcastMessage (const String& value) //============================================================================== void MessageManager::doPlatformSpecificInitialisation() { - OleInitialize (0); + OleInitialize (nullptr); InternalMessageQueue::getInstance(); } diff --git a/modules/juce_graphics/native/juce_win32_Fonts.cpp b/modules/juce_graphics/native/juce_win32_Fonts.cpp index 7300d61ac4..73e8db6f6c 100644 --- a/modules/juce_graphics/native/juce_win32_Fonts.cpp +++ b/modules/juce_graphics/native/juce_win32_Fonts.cpp @@ -157,7 +157,7 @@ namespace FontEnumerators const String fontName (lpelfe->elfLogFont.lfFaceName); fontName.copyToUTF16 (lf.lfFaceName, sizeof (lf.lfFaceName)); - auto dc = CreateCompatibleDC (0); + auto dc = CreateCompatibleDC (nullptr); EnumFontFamiliesEx (dc, &lf, (FONTENUMPROCW) &fontEnum2, lParam, 0); DeleteDC (dc); } @@ -190,7 +190,7 @@ StringArray Font::findAllTypefaceNames() else #endif { - auto dc = CreateCompatibleDC (0); + auto dc = CreateCompatibleDC (nullptr); { LOGFONTW lf = {}; @@ -332,10 +332,10 @@ public: SelectObject (dc, previousFontH); // Replacing the previous font before deleting the DC avoids a warning in BoundsChecker DeleteDC (dc); - if (fontH != 0) + if (fontH != nullptr) DeleteObject (fontH); - if (memoryFont != 0) + if (memoryFont != nullptr) RemoveFontMemResourceEx (memoryFont); } @@ -392,13 +392,13 @@ public: GLYPHMETRICS gm; // (although GetGlyphOutline returns a DWORD, it may be -1 on failure, so treat it as signed int..) auto bufSize = (int) GetGlyphOutline (dc, (UINT) glyphNumber, GGO_NATIVE | GGO_GLYPH_INDEX, - &gm, 0, 0, &identityMatrix); + &gm, 0, nullptr, &identityMatrix); if (bufSize > 0) { HeapBlock data (bufSize); GetGlyphOutline (dc, (UINT) glyphNumber, GGO_NATIVE | GGO_GLYPH_INDEX, &gm, - bufSize, data, &identityMatrix); + (DWORD) bufSize, data, &identityMatrix); auto pheader = reinterpret_cast (data.getData()); @@ -456,7 +456,7 @@ private: static const MAT2 identityMatrix; HFONT fontH = {}; HGDIOBJ previousFontH = {}; - HDC dc { CreateCompatibleDC (0) }; + HDC dc { CreateCompatibleDC (nullptr) }; TEXTMETRIC tm; HANDLE memoryFont = {}; float ascent = 1.0f, heightToPointsFactor = 1.0f; @@ -486,17 +486,17 @@ private: auto standardSizedFont = CreateFontIndirect (&lf); - if (standardSizedFont != 0) + if (standardSizedFont != nullptr) { - if ((previousFontH = SelectObject (dc, standardSizedFont)) != 0) + if ((previousFontH = SelectObject (dc, standardSizedFont)) != nullptr) { fontH = standardSizedFont; OUTLINETEXTMETRIC otm; if (GetOutlineTextMetrics (dc, sizeof (otm), &otm) != 0) { - heightInPoints = otm.otmEMSquare; - lf.lfHeight = -(int) heightInPoints; + heightInPoints = (int) otm.otmEMSquare; + lf.lfHeight = -heightInPoints; fontH = CreateFontIndirect (&lf); SelectObject (dc, fontH); @@ -519,7 +519,7 @@ private: void createKerningPairs (HDC hdc, std::unordered_map& glyphsForChars, float height) { HeapBlock rawKerning; - auto numKPs = GetKerningPairs (hdc, 0, 0); + auto numKPs = GetKerningPairs (hdc, 0, nullptr); rawKerning.calloc (numKPs); GetKerningPairs (hdc, numKPs, rawKerning); @@ -570,7 +570,7 @@ private: { GLYPHMETRICS gm; gm.gmCellIncX = 0; - GetGlyphOutline (dc, (UINT) glyphNumber, GGO_NATIVE | GGO_GLYPH_INDEX, &gm, 0, 0, &identityMatrix); + GetGlyphOutline (dc, (UINT) glyphNumber, GGO_NATIVE | GGO_GLYPH_INDEX, &gm, 0, nullptr, &identityMatrix); return gm.gmCellIncX; } diff --git a/modules/juce_gui_basics/native/juce_win32_DragAndDrop.cpp b/modules/juce_gui_basics/native/juce_win32_DragAndDrop.cpp index c2816716bb..4e8a0d4b71 100644 --- a/modules/juce_gui_basics/native/juce_win32_DragAndDrop.cpp +++ b/modules/juce_gui_basics/native/juce_win32_DragAndDrop.cpp @@ -50,7 +50,7 @@ namespace DragAndDropHelpers JUCE_COMRESULT Clone (IEnumFORMATETC** result) override { - if (result == 0) + if (result == nullptr) return E_POINTER; auto newOne = new JuceEnumFormatEtc (format); @@ -66,7 +66,7 @@ namespace DragAndDropHelpers else if (celt != 1) return S_FALSE; - if (index == 0 && celt > 0 && lpFormatEtc != 0) + if (index == 0 && celt > 0 && lpFormatEtc != nullptr) { copyFormatEtc (lpFormatEtc [0], *format); ++index; @@ -85,7 +85,7 @@ namespace DragAndDropHelpers if (index + (int) celt >= 1) return S_FALSE; - index += celt; + index += (int) celt; return S_OK; } @@ -103,7 +103,7 @@ namespace DragAndDropHelpers { dest = source; - if (source.ptd != 0) + if (source.ptd != nullptr) { dest.ptd = (DVTARGETDEVICE*) CoTaskMemAlloc (sizeof (DVTARGETDEVICE)); *(dest.ptd) = *(source.ptd); @@ -134,7 +134,7 @@ namespace DragAndDropHelpers && pFormatEtc->dwAspect == format->dwAspect) { pMedium->tymed = format->tymed; - pMedium->pUnkForRelease = 0; + pMedium->pUnkForRelease = nullptr; if (format->tymed == TYMED_HGLOBAL) { @@ -156,7 +156,7 @@ namespace DragAndDropHelpers JUCE_COMRESULT QueryGetData (FORMATETC* f) { - if (f == 0) + if (f == nullptr) return E_INVALIDARG; if (f->tymed == format->tymed @@ -169,13 +169,13 @@ namespace DragAndDropHelpers JUCE_COMRESULT GetCanonicalFormatEtc (FORMATETC*, FORMATETC* pFormatEtcOut) { - pFormatEtcOut->ptd = 0; + pFormatEtcOut->ptd = nullptr; return E_NOTIMPL; } JUCE_COMRESULT EnumFormatEtc (DWORD direction, IEnumFORMATETC** result) { - if (result == 0) + if (result == nullptr) return E_POINTER; if (direction == DATADIR_GET) @@ -184,7 +184,7 @@ namespace DragAndDropHelpers return S_OK; } - *result = 0; + *result = nullptr; return E_NOTIMPL; } @@ -204,13 +204,13 @@ namespace DragAndDropHelpers //============================================================================== HDROP createHDrop (const StringArray& fileNames) { - int totalBytes = 0; + size_t totalBytes = 0; for (int i = fileNames.size(); --i >= 0;) - totalBytes += (int) CharPointer_UTF16::getBytesRequiredFor (fileNames[i].getCharPointer()) + sizeof (WCHAR); + totalBytes += CharPointer_UTF16::getBytesRequiredFor (fileNames[i].getCharPointer()) + sizeof (WCHAR); HDROP hDrop = (HDROP) GlobalAlloc (GMEM_MOVEABLE | GMEM_ZEROINIT, sizeof (DROPFILES) + totalBytes + 4); - if (hDrop != 0) + if (hDrop != nullptr) { auto pDropFiles = (LPDROPFILES) GlobalLock (hDrop); pDropFiles->pFiles = sizeof (DROPFILES); @@ -243,7 +243,7 @@ namespace DragAndDropHelpers JobStatus runJob() override { - OleInitialize (0); + OleInitialize (nullptr); auto source = new JuceDropSource(); auto data = new JuceDataObject (&format, &medium); @@ -300,8 +300,8 @@ bool DragAndDropContainer::performExternalDragDropOfFiles (const StringArray& fi if (files.isEmpty()) return false; - FORMATETC format = { CF_HDROP, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }; - STGMEDIUM medium = { TYMED_HGLOBAL, { 0 }, 0 }; + FORMATETC format = { CF_HDROP, nullptr, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }; + STGMEDIUM medium = { TYMED_HGLOBAL, { nullptr }, nullptr }; medium.hGlobal = DragAndDropHelpers::createHDrop (files); @@ -319,8 +319,8 @@ bool DragAndDropContainer::performExternalDragDropOfText (const String& text, Co if (text.isEmpty()) return false; - FORMATETC format = { CF_TEXT, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }; - STGMEDIUM medium = { TYMED_HGLOBAL, { 0 }, 0 }; + FORMATETC format = { CF_TEXT, nullptr, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }; + STGMEDIUM medium = { TYMED_HGLOBAL, { nullptr }, nullptr }; auto numBytes = CharPointer_UTF16::getBytesRequiredFor (text.getCharPointer()); diff --git a/modules/juce_gui_basics/native/juce_win32_FileChooser.cpp b/modules/juce_gui_basics/native/juce_win32_FileChooser.cpp index aa21e6e4f8..39e9734cad 100644 --- a/modules/juce_gui_basics/native/juce_win32_FileChooser.cpp +++ b/modules/juce_gui_basics/native/juce_win32_FileChooser.cpp @@ -363,7 +363,7 @@ private: auto scale = Desktop::getInstance().getDisplays().findDisplayForRect (screenRectangle, true).scale; auto physicalComponentWidth = roundToInt (safeCustomComponent->getWidth() * scale); - SetWindowPos (hdlg, 0, screenRectangle.getX(), screenRectangle.getY(), + SetWindowPos (hdlg, nullptr, screenRectangle.getX(), screenRectangle.getY(), physicalComponentWidth + jmax (150, screenRectangle.getWidth()), jmax (150, screenRectangle.getHeight()), SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOZORDER); @@ -494,7 +494,7 @@ private: HWND dialogH = GetParent (hwnd); - if (dialogH == 0) + if (dialogH == nullptr) dialogH = hwnd; return dialogH; diff --git a/modules/juce_gui_basics/native/juce_win32_Windowing.cpp b/modules/juce_gui_basics/native/juce_win32_Windowing.cpp index 6c2a7d17fe..c67ed59817 100644 --- a/modules/juce_gui_basics/native/juce_win32_Windowing.cpp +++ b/modules/juce_gui_basics/native/juce_win32_Windowing.cpp @@ -27,6 +27,8 @@ namespace juce { +JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wcast-function-type") + #undef GetSystemMetrics // multimon overrides this for some reason and causes a mess.. // these are in the windows SDK, but need to be repeated here for GCC.. @@ -44,16 +46,15 @@ namespace juce #define WM_APPCOMMAND 0x0319 #endif -extern void juce_repeatLastProcessPriority(); -extern void juce_checkCurrentlyFocusedTopLevelWindow(); // in juce_TopLevelWindow.cpp -extern bool juce_isRunningInWine(); +void juce_repeatLastProcessPriority(); +bool juce_isRunningInWine(); using CheckEventBlockedByModalComps = bool (*) (const MSG&); extern CheckEventBlockedByModalComps isEventBlockedByModalComps; static bool shouldDeactivateTitleBar = true; -extern void* getUser32Function (const char*); +void* getUser32Function (const char*); //============================================================================== #ifndef WM_TOUCH @@ -356,7 +357,7 @@ static void setDPIAwareness() HMODULE shcoreModule = GetModuleHandleA ("SHCore.dll"); - if (shcoreModule != 0) + if (shcoreModule != nullptr) { getDPIForMonitor = (GetDPIForMonitorFunc) GetProcAddress (shcoreModule, "GetDpiForMonitor"); @@ -407,7 +408,7 @@ static bool isPerMonitorDPIAwareProcess() return false; DPI_Awareness context; - getProcessDPIAwareness (0, &context); + getProcessDPIAwareness (nullptr, &context); return context == DPI_Awareness::DPI_Awareness_Per_Monitor_Aware; }(); @@ -453,9 +454,9 @@ static double getGlobalDPI() { setDPIAwareness(); - HDC dc = GetDC (0); + HDC dc = GetDC (nullptr); auto dpi = (GetDeviceCaps (dc, LOGPIXELSX) + GetDeviceCaps (dc, LOGPIXELSY)) / 2.0; - ReleaseDC (0, dc); + ReleaseDC (nullptr, dc); return dpi; } @@ -588,7 +589,7 @@ static void setWindowPos (HWND hwnd, Rectangle bounds, UINT flags, bool adj bounds = convertLogicalScreenRectangleToPhysical (bounds, hwnd); } - SetWindowPos (hwnd, 0, bounds.getX(), bounds.getY(), bounds.getWidth(), bounds.getHeight(), flags); + SetWindowPos (hwnd, nullptr, bounds.getX(), bounds.getY(), bounds.getWidth(), bounds.getHeight(), flags); } static RECT getWindowRect (HWND hwnd) @@ -758,14 +759,14 @@ public: bitmapInfo.bV4V4Compression = BI_RGB; } - HDC dc = GetDC (0); + HDC dc = GetDC (nullptr); hdc = CreateCompatibleDC (dc); - ReleaseDC (0, dc); + ReleaseDC (nullptr, dc); SetMapMode (hdc, MM_TEXT); hBitmap = CreateDIBSection (hdc, (BITMAPINFO*) &(bitmapInfo), DIB_RGB_COLORS, - (void**) &bitmapData, 0, 0); + (void**) &bitmapData, nullptr, 0); previousBitmap = SelectObject (hdc, hBitmap); @@ -830,7 +831,7 @@ public: bf.BlendOp = AC_SRC_OVER; bf.SourceConstantAlpha = updateLayeredWindowAlpha; - UpdateLayeredWindow (hwnd, 0, &pos, &size, hdc, &p, 0, &bf, 2 /*ULW_ALPHA*/); + UpdateLayeredWindow (hwnd, nullptr, &pos, &size, hdc, &p, 0, &bf, 2 /*ULW_ALPHA*/); } else { @@ -853,9 +854,9 @@ public: private: static bool isGraphicsCard32Bit() { - auto dc = GetDC (0); + auto dc = GetDC (nullptr); auto bitsPerPixel = GetDeviceCaps (dc, BITSPIXEL); - ReleaseDC (0, dc); + ReleaseDC (nullptr, dc); return bitsPerPixel > 24; } @@ -962,7 +963,7 @@ namespace IconConverters auto oldObject = ::SelectObject (dc, dib); auto numPixels = bm.bmWidth * bm.bmHeight; - auto numColourComponents = numPixels * 4; + auto numColourComponents = (size_t) numPixels * 4; // Windows icon data comes as two layers, an XOR mask which contains the bulk // of the image data and an AND mask which provides the transparency. Annoyingly @@ -1024,7 +1025,7 @@ namespace IconConverters g.drawImageAt (image, 0, 0); } - auto mask = CreateBitmap (image.getWidth(), image.getHeight(), 1, 1, 0); + auto mask = CreateBitmap (image.getWidth(), image.getHeight(), 1, 1, nullptr); ICONINFO info; info.fIcon = isIcon; @@ -1307,7 +1308,7 @@ public: callFunctionIfNotLocked (&destroyWindowCallback, (void*) hwnd); - if (currentWindowIcon != 0) + if (currentWindowIcon != nullptr) DestroyIcon (currentWindowIcon); if (dropTarget != nullptr) @@ -1330,7 +1331,7 @@ public: ShowWindow (hwnd, shouldBeVisible ? SW_SHOWNA : SW_HIDE); if (shouldBeVisible) - InvalidateRect (hwnd, 0, 0); + InvalidateRect (hwnd, nullptr, 0); else lastPaintTime = 0; } @@ -1449,7 +1450,7 @@ public: else { SetWindowLong (hwnd, GWL_EXSTYLE, GetWindowLong (hwnd, GWL_EXSTYLE) & ~WS_EX_LAYERED); - RedrawWindow (hwnd, 0, 0, RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN); + RedrawWindow (hwnd, nullptr, nullptr, RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN); } } else @@ -1602,7 +1603,7 @@ public: bool isFocused() const override { - return callFunctionIfNotLocked (&getFocusCallback, 0) == (void*) hwnd; + return callFunctionIfNotLocked (&getFocusCallback, nullptr) == (void*) hwnd; } void grabFocus() override @@ -1671,7 +1672,7 @@ public: //============================================================================== static HWNDComponentPeer* getOwnerOfWindow (HWND h) noexcept { - if (h != 0 && JuceWindowIdentifier::isJUCEWindow (h)) + if (h != nullptr && JuceWindowIdentifier::isJUCEWindow (h)) return (HWNDComponentPeer*) GetWindowLongPtr (h, 8); return nullptr; @@ -1808,8 +1809,8 @@ public: { DroppedData (IDataObject* dataObject, CLIPFORMAT type) { - FORMATETC format = { type, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }; - STGMEDIUM resetMedium = { TYMED_HGLOBAL, { 0 }, 0 }; + FORMATETC format = { type, nullptr, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }; + STGMEDIUM resetMedium = { TYMED_HGLOBAL, { nullptr }, nullptr }; medium = resetMedium; if (SUCCEEDED (error = dataObject->GetData (&format, &medium))) @@ -1914,7 +1915,7 @@ private: bool fullScreen = false, isDragging = false, isMouseOver = false, hasCreatedCaret = false, constrainerIsResizing = false; BorderSize windowBorder; - HICON currentWindowIcon = 0; + HICON currentWindowIcon = nullptr; FileDropTarget* dropTarget = nullptr; uint8 updateLayeredWindowAlpha = 255; UWPUIViewSettings uwpViewSettings; @@ -2111,7 +2112,7 @@ private: if ((styleFlags & windowIsResizable) != 0) type |= WS_THICKFRAME; } - else if (parentToAddTo != 0) + else if (parentToAddTo != nullptr) { type |= WS_CHILD; } @@ -2131,10 +2132,10 @@ private: if ((styleFlags & windowIsSemiTransparent) != 0) exstyle |= WS_EX_LAYERED; hwnd = CreateWindowEx (exstyle, WindowClassHolder::getInstance()->getWindowClassName(), - L"", type, 0, 0, 0, 0, parentToAddTo, 0, - (HINSTANCE) Process::getCurrentModuleInstanceHandle(), 0); + L"", type, 0, 0, 0, 0, parentToAddTo, nullptr, + (HINSTANCE) Process::getCurrentModuleInstanceHandle(), nullptr); - if (hwnd != 0) + if (hwnd != nullptr) { SetWindowLongPtr (hwnd, 0, 0); SetWindowLongPtr (hwnd, 8, (LONG_PTR) this); @@ -2265,7 +2266,7 @@ private: SendMessage (hwnd, WM_SETICON, ICON_BIG, (LPARAM) hicon); SendMessage (hwnd, WM_SETICON, ICON_SMALL, (LPARAM) hicon); - if (currentWindowIcon != 0) + if (currentWindowIcon != nullptr) DestroyIcon (currentWindowIcon); currentWindowIcon = hicon; @@ -2523,7 +2524,7 @@ private: #endif } - static int getMinTimeBetweenMouseMoves() + static uint32 getMinTimeBetweenMouseMoves() { if (SystemStats::getOperatingSystemType() >= SystemStats::WinVista) return 0; @@ -2781,7 +2782,7 @@ private: HeapBlock inputInfo (numInputs); - if (getTouchInputInfo (eventHandle, numInputs, inputInfo, sizeof (TOUCHINPUT))) + if (getTouchInputInfo (eventHandle, (UINT) numInputs, inputInfo, sizeof (TOUCHINPUT))) { for (int i = 0; i < numInputs; ++i) { @@ -3292,7 +3293,7 @@ private: ScreenToClient (GetParent (hwnd), &p); auto ratio = *(double*) context; - SetWindowPos (hwnd, 0, roundToInt (p.x * ratio), roundToInt (p.y * ratio), + SetWindowPos (hwnd, nullptr, roundToInt (p.x * ratio), roundToInt (p.y * ratio), roundToInt ((r.right - r.left) * ratio), roundToInt ((r.bottom - r.top) * ratio), SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOOWNERZORDER); @@ -3722,7 +3723,7 @@ private: return 0; case WM_DISPLAYCHANGE: - InvalidateRect (h, 0, 0); + InvalidateRect (h, nullptr, 0); // intentional fall-through... JUCE_FALLTHROUGH case WM_SETTINGCHANGE: // note the fall-through in the previous case! @@ -3951,14 +3952,14 @@ private: String getCompositionString (HIMC hImc, const DWORD type) const { - jassert (hImc != 0); + jassert (hImc != nullptr); - const int stringSizeBytes = ImmGetCompositionString (hImc, type, 0, 0); + const auto stringSizeBytes = ImmGetCompositionString (hImc, type, nullptr, 0); if (stringSizeBytes > 0) { HeapBlock buffer; - buffer.calloc (stringSizeBytes / sizeof (TCHAR) + 1); + buffer.calloc ((size_t) stringSizeBytes / sizeof (TCHAR) + 1); ImmGetCompositionString (hImc, type, buffer, (DWORD) stringSizeBytes); return String (buffer.get()); } @@ -3968,14 +3969,14 @@ private: int getCompositionCaretPos (HIMC hImc, LPARAM lParam, const String& currentIMEString) const { - jassert (hImc != 0); + jassert (hImc != nullptr); if ((lParam & CS_NOMOVECARET) != 0) return compositionRange.getStart(); if ((lParam & GCS_CURSORPOS) != 0) { - const int localCaretPos = ImmGetCompositionString (hImc, GCS_CURSORPOS, 0, 0); + const int localCaretPos = ImmGetCompositionString (hImc, GCS_CURSORPOS, nullptr, 0); return compositionRange.getStart() + jmax (0, localCaretPos); } @@ -3986,14 +3987,14 @@ private: // returned range is relative to beginning of TextInputTarget, not composition string Range getCompositionSelection (HIMC hImc, LPARAM lParam) const { - jassert (hImc != 0); + jassert (hImc != nullptr); int selectionStart = 0; int selectionEnd = 0; if ((lParam & GCS_COMPATTR) != 0) { // Get size of attributes array: - const int attributeSizeBytes = ImmGetCompositionString (hImc, GCS_COMPATTR, 0, 0); + const int attributeSizeBytes = ImmGetCompositionString (hImc, GCS_COMPATTR, nullptr, 0); if (attributeSizeBytes > 0) { @@ -4034,13 +4035,13 @@ private: { Array> result; - if (hImc != 0 && (lParam & GCS_COMPCLAUSE) != 0) + if (hImc != nullptr && (lParam & GCS_COMPCLAUSE) != 0) { - auto clauseDataSizeBytes = ImmGetCompositionString (hImc, GCS_COMPCLAUSE, 0, 0); + auto clauseDataSizeBytes = ImmGetCompositionString (hImc, GCS_COMPCLAUSE, nullptr, 0); if (clauseDataSizeBytes > 0) { - const size_t numItems = clauseDataSizeBytes / sizeof (uint32); + const auto numItems = (size_t) clauseDataSizeBytes / sizeof (uint32); HeapBlock clauseData (numItems); if (ImmGetCompositionString (hImc, GCS_COMPCLAUSE, clauseData, (DWORD) clauseDataSizeBytes) > 0) @@ -4228,6 +4229,7 @@ private: case AlertWindow::QuestionIcon: flags |= MB_ICONQUESTION; break; case AlertWindow::WarningIcon: flags |= MB_ICONWARNING; break; case AlertWindow::InfoIcon: flags |= MB_ICONINFORMATION; break; + case AlertWindow::NoIcon: JUCE_FALLTHROUGH default: break; } @@ -4236,7 +4238,7 @@ private: static HWND getWindowForMessageBox (Component* associatedComponent) { - return associatedComponent != nullptr ? (HWND) associatedComponent->getWindowHandle() : 0; + return associatedComponent != nullptr ? (HWND) associatedComponent->getWindowHandle() : nullptr; } }; @@ -4245,7 +4247,7 @@ void JUCE_CALLTYPE NativeMessageBox::showMessageBox (AlertWindow::AlertIconType const String& title, const String& message, Component* associatedComponent) { - WindowsMessageBox box (iconType, title, message, associatedComponent, MB_OK, 0, false); + WindowsMessageBox box (iconType, title, message, associatedComponent, MB_OK, nullptr, false); (void) box.getResult(); } #endif @@ -4395,7 +4397,7 @@ void LookAndFeel::playAlertSound() //============================================================================== void SystemClipboard::copyTextToClipboard (const String& text) { - if (OpenClipboard (0) != 0) + if (OpenClipboard (nullptr) != 0) { if (EmptyClipboard() != 0) { @@ -4424,7 +4426,7 @@ String SystemClipboard::getTextFromClipboard() { String result; - if (OpenClipboard (0) != 0) + if (OpenClipboard (nullptr) != 0) { if (auto bufH = GetClipboardData (CF_UNICODETEXT)) { @@ -4541,7 +4543,7 @@ void Displays::findDisplays (float masterScale) setDPIAwareness(); Array monitors; - EnumDisplayMonitors (0, 0, &enumMonitorsProc, (LPARAM) &monitors); + EnumDisplayMonitors (nullptr, nullptr, &enumMonitorsProc, (LPARAM) &monitors); auto globalDPI = getGlobalDPI(); @@ -4719,14 +4721,15 @@ void* MouseCursor::createStandardMouseCursor (const MouseCursor::StandardCursorT return copyCursor; } + case NumStandardCursorTypes: JUCE_FALLTHROUGH default: jassertfalse; break; } - if (auto cursorH = LoadCursor (0, cursorName)) + if (auto cursorH = LoadCursor (nullptr, cursorName)) return cursorH; - return LoadCursor (0, IDC_ARROW); + return LoadCursor (nullptr, IDC_ARROW); } //============================================================================== @@ -4734,12 +4737,14 @@ void MouseCursor::showInWindow (ComponentPeer*) const { auto c = (HCURSOR) getHandle(); - if (c == 0) - c = LoadCursor (0, IDC_ARROW); + if (c == nullptr) + c = LoadCursor (nullptr, IDC_ARROW); else if (c == (HCURSOR) hiddenMouseCursorHandle) - c = 0; + c = nullptr; SetCursor (c); } +JUCE_END_IGNORE_WARNINGS_GCC_LIKE + } // namespace juce diff --git a/modules/juce_gui_extra/native/juce_win32_ActiveXComponent.cpp b/modules/juce_gui_extra/native/juce_win32_ActiveXComponent.cpp index 4c52fc48fb..d9fe7da12e 100644 --- a/modules/juce_gui_extra/native/juce_win32_ActiveXComponent.cpp +++ b/modules/juce_gui_extra/native/juce_win32_ActiveXComponent.cpp @@ -107,7 +107,7 @@ namespace ActiveXHelpers if (lplpDoc != nullptr) *lplpDoc = nullptr; lpFrameInfo->fMDIApp = FALSE; lpFrameInfo->hwndFrame = window; - lpFrameInfo->haccel = 0; + lpFrameInfo->haccel = nullptr; lpFrameInfo->cAccelEntries = 0; return S_OK; } @@ -256,7 +256,7 @@ public: void setControlBounds (Rectangle newBounds) const { - if (controlHWND != 0) + if (controlHWND != nullptr) { #if JUCE_WIN_PER_MONITOR_DPI_AWARE if (auto* peer = owner.getTopLevelComponent()->getPeer()) @@ -270,11 +270,13 @@ public: void setControlVisible (bool shouldBeVisible) const { - if (controlHWND != 0) + if (controlHWND != nullptr) ShowWindow (controlHWND, shouldBeVisible ? SW_SHOWNA : SW_HIDE); } //============================================================================== + using ComponentMovementWatcher::componentMovedOrResized; + void componentMovedOrResized (bool /*wasMoved*/, bool /*wasResized*/) override { if (auto* peer = owner.getTopLevelComponent()->getPeer()) @@ -291,6 +293,8 @@ public: #endif } + using ComponentMovementWatcher::componentVisibilityChanged; + void componentVisibilityChanged() override { setControlVisible (owner.isShowing()); @@ -351,7 +355,7 @@ public: IStorage* storage = nullptr; ActiveXHelpers::JuceIOleClientSite* clientSite = nullptr; IOleObject* control = nullptr; - WNDPROC originalWndProc = 0; + WNDPROC originalWndProc = nullptr; }; //============================================================================== @@ -383,13 +387,13 @@ bool ActiveXControlComponent::createControl (const void* controlIID) std::unique_ptr newControl (new Pimpl (hwnd, *this)); - HRESULT hr = OleCreate (*(const IID*) controlIID, __uuidof (IOleObject), 1 /*OLERENDER_DRAW*/, 0, + HRESULT hr = OleCreate (*(const IID*) controlIID, __uuidof (IOleObject), 1 /*OLERENDER_DRAW*/, nullptr, newControl->clientSite, newControl->storage, (void**) &(newControl->control)); if (hr == S_OK) { - newControl->control->SetHostNames (L"JUCE", 0); + newControl->control->SetHostNames (L"JUCE", nullptr); if (OleSetContainedObject (newControl->control, TRUE) == S_OK) { @@ -399,12 +403,12 @@ bool ActiveXControlComponent::createControl (const void* controlIID) rect.right = controlBounds.getRight(); rect.bottom = controlBounds.getBottom(); - if (newControl->control->DoVerb (OLEIVERB_SHOW, 0, newControl->clientSite, 0, hwnd, &rect) == S_OK) + if (newControl->control->DoVerb (OLEIVERB_SHOW, nullptr, newControl->clientSite, 0, hwnd, &rect) == S_OK) { control.reset (newControl.release()); control->controlHWND = ActiveXHelpers::getHWND (this); - if (control->controlHWND != 0) + if (control->controlHWND != nullptr) { control->setControlBounds (controlBounds); diff --git a/modules/juce_gui_extra/native/juce_win32_HWNDComponent.cpp b/modules/juce_gui_extra/native/juce_win32_HWNDComponent.cpp index 31149d0741..7b9662943c 100644 --- a/modules/juce_gui_extra/native/juce_win32_HWNDComponent.cpp +++ b/modules/juce_gui_extra/native/juce_win32_HWNDComponent.cpp @@ -37,6 +37,8 @@ public: DestroyWindow (hwnd); } + using ComponentMovementWatcher::componentMovedOrResized; + void componentMovedOrResized (bool wasMoved, bool wasResized) override { auto* topComponent = owner.getTopLevelComponent(); @@ -52,7 +54,7 @@ public: if (! wasMoved) windowFlags |= SWP_NOMOVE; if (! wasResized) windowFlags |= SWP_NOSIZE; - SetWindowPos (hwnd, 0, scaled.getX(), scaled.getY(), scaled.getWidth(), scaled.getHeight(), windowFlags); + SetWindowPos (hwnd, nullptr, scaled.getX(), scaled.getY(), scaled.getWidth(), scaled.getHeight(), windowFlags); } } @@ -73,9 +75,11 @@ public: ShowWindow (hwnd, isShowing ? SW_SHOWNA : SW_HIDE); if (isShowing) - InvalidateRect (hwnd, 0, 0); + InvalidateRect (hwnd, nullptr, 0); } + using ComponentMovementWatcher::componentVisibilityChanged; + void componentVisibilityChanged() override { componentPeerChanged(); diff --git a/modules/juce_opengl/native/juce_OpenGL_win32.h b/modules/juce_opengl/native/juce_OpenGL_win32.h index a2d57d2b3a..bc6d8e7e82 100644 --- a/modules/juce_opengl/native/juce_OpenGL_win32.h +++ b/modules/juce_opengl/native/juce_OpenGL_win32.h @@ -51,7 +51,7 @@ public: renderContext = wglCreateContext (dc); - if (renderContext != 0) + if (renderContext != nullptr) { makeActive(); initialiseGLExtensions(); @@ -100,7 +100,7 @@ public: void shutdownOnRenderThread() { deactivateCurrentContext(); context = nullptr; } - static void deactivateCurrentContext() { wglMakeCurrent (0, 0); } + static void deactivateCurrentContext() { wglMakeCurrent (nullptr, nullptr); } bool makeActive() const noexcept { return isActive() || wglMakeCurrent (dc, renderContext) != FALSE; } bool isActive() const noexcept { return wglGetCurrentContext() == renderContext; } void swapBuffers() const noexcept { SwapBuffers (dc); } @@ -124,7 +124,7 @@ public: if (! approximatelyEqual (nativeScaleFactor, 1.0)) bounds = (bounds.toDouble() * nativeScaleFactor).toNearestInt(); - SetWindowPos ((HWND) nativeWindow->getNativeHandle(), 0, + SetWindowPos ((HWND) nativeWindow->getNativeHandle(), nullptr, bounds.getX(), bounds.getY(), bounds.getWidth(), bounds.getHeight(), SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOOWNERZORDER); } @@ -232,10 +232,10 @@ private: void deleteRenderContext() { - if (renderContext != 0) + if (renderContext != nullptr) { wglDeleteContext (renderContext); - renderContext = 0; + renderContext = nullptr; } } @@ -322,7 +322,7 @@ private: //============================================================================== bool OpenGLHelpers::isContextActive() { - return wglGetCurrentContext() != 0; + return wglGetCurrentContext() != nullptr; } } // namespace juce