diff --git a/DeviceAdapters/89NorthLDI/LDI.cpp b/DeviceAdapters/89NorthLDI/LDI.cpp index 63409f0fb..9921a35a9 100644 --- a/DeviceAdapters/89NorthLDI/LDI.cpp +++ b/DeviceAdapters/89NorthLDI/LDI.cpp @@ -2,6 +2,9 @@ #include +#define WIN32_LEAN_AND_MEAN +#include + const char* g_LDI_name = "89 North Laser Diode Illuminator"; const char* g_LDI_description = "Multi-line, Solid-State Laser Illuminator"; #define LDI_ERROR 108901 diff --git a/DeviceAdapters/ABS/AbsImgBuffer.h b/DeviceAdapters/ABS/AbsImgBuffer.h index acc88835a..2d18baf2e 100644 --- a/DeviceAdapters/ABS/AbsImgBuffer.h +++ b/DeviceAdapters/ABS/AbsImgBuffer.h @@ -2,6 +2,9 @@ #include "ImgBuffer.h" //!< base class #include "DeviceThreads.h" //!< MMThreadLock class +#define WIN32_LEAN_AND_MEAN +#include + // ---------------------------Camera - API ------------------------------------ #include "common_structs_exp.h" //!< ABS Camera API structs diff --git a/DeviceAdapters/AndorShamrock/AndorShamrock.cpp b/DeviceAdapters/AndorShamrock/AndorShamrock.cpp index f5bdd1b70..b0afb05ae 100755 --- a/DeviceAdapters/AndorShamrock/AndorShamrock.cpp +++ b/DeviceAdapters/AndorShamrock/AndorShamrock.cpp @@ -1,7 +1,10 @@ #include "AndorShamrock.h" #include "ModuleAPIFunctions.h" + +#define WIN32_LEAN_AND_MEAN +#include + #include "ShamrockCIF.h" -//#include "ShamrockConstants.h" #include using namespace std; diff --git a/DeviceAdapters/BaumerOptronic/BaumerOptronic.h b/DeviceAdapters/BaumerOptronic/BaumerOptronic.h index cfd84e7f0..a22cd46f4 100644 --- a/DeviceAdapters/BaumerOptronic/BaumerOptronic.h +++ b/DeviceAdapters/BaumerOptronic/BaumerOptronic.h @@ -27,6 +27,9 @@ #include "ImgBuffer.h" #include "DeviceThreads.h" +#define WIN32_LEAN_AND_MEAN +#include + #pragma warning(push) #pragma warning(disable: 4245) #include "FxApi.h" diff --git a/DeviceAdapters/DemoCamera/DemoCamera.cpp b/DeviceAdapters/DemoCamera/DemoCamera.cpp index 960af4d73..7c270b48a 100644 --- a/DeviceAdapters/DemoCamera/DemoCamera.cpp +++ b/DeviceAdapters/DemoCamera/DemoCamera.cpp @@ -37,6 +37,8 @@ #include #ifdef _WIN32 + #define WIN32_LEAN_AND_MEAN + #include #include #endif diff --git a/DeviceAdapters/Dragonfly/TIRFIntensity.cpp b/DeviceAdapters/Dragonfly/TIRFIntensity.cpp index 453fc7bdd..b39597bd5 100644 --- a/DeviceAdapters/Dragonfly/TIRFIntensity.cpp +++ b/DeviceAdapters/Dragonfly/TIRFIntensity.cpp @@ -4,6 +4,9 @@ #include "ConfocalMode.h" #include "Dragonfly.h" +#define WIN32_LEAN_AND_MEAN +#include + const char* const g_TIRFIntensityPropertyName = "TIRF | Optical Feedback"; const char* const g_TIRFIntensityLimitsReadError = "Failed to retrieve TIRF intensity limits"; const char* const g_TIRFIntensityValueReadError = "Failed to retrieve the current TIRF intensity"; diff --git a/DeviceAdapters/Elveflow/mux_distrib.cpp b/DeviceAdapters/Elveflow/mux_distrib.cpp index 9ffb98bfb..2137ecbc8 100644 --- a/DeviceAdapters/Elveflow/mux_distrib.cpp +++ b/DeviceAdapters/Elveflow/mux_distrib.cpp @@ -1,9 +1,11 @@ #include "ModuleInterface.h" #include "mux_distrib.h" -#include "iostream" +#include #include #include -#include + +#define WIN32_LEAN_AND_MEAN +#include using namespace std; diff --git a/DeviceAdapters/Elveflow/mux_wire_v3.cpp b/DeviceAdapters/Elveflow/mux_wire_v3.cpp index 4944f8284..939a9bf69 100644 --- a/DeviceAdapters/Elveflow/mux_wire_v3.cpp +++ b/DeviceAdapters/Elveflow/mux_wire_v3.cpp @@ -1,9 +1,8 @@ #include "ModuleInterface.h" #include "mux_wire_v3.h" -#include "iostream" +#include #include #include -#include using namespace std; diff --git a/DeviceAdapters/Elveflow/mux_wire_v3.h b/DeviceAdapters/Elveflow/mux_wire_v3.h index 9e54ba08a..9087d1aad 100644 --- a/DeviceAdapters/Elveflow/mux_wire_v3.h +++ b/DeviceAdapters/Elveflow/mux_wire_v3.h @@ -2,6 +2,9 @@ #include "DeviceUtils.h" #include +#define WIN32_LEAN_AND_MEAN +#include + using namespace std; class MuxWireV3 : public CGenericBase { diff --git a/DeviceAdapters/Elveflow/ob1_mk4.cpp b/DeviceAdapters/Elveflow/ob1_mk4.cpp index a8a647d38..2eae372ab 100644 --- a/DeviceAdapters/Elveflow/ob1_mk4.cpp +++ b/DeviceAdapters/Elveflow/ob1_mk4.cpp @@ -1,9 +1,8 @@ #include "ModuleInterface.h" #include "ob1_mk4.h" -#include "iostream" +#include #include #include -#include using namespace std; diff --git a/DeviceAdapters/Elveflow/ob1_mk4.h b/DeviceAdapters/Elveflow/ob1_mk4.h index 9c91505f3..411234799 100644 --- a/DeviceAdapters/Elveflow/ob1_mk4.h +++ b/DeviceAdapters/Elveflow/ob1_mk4.h @@ -2,6 +2,9 @@ #include "DeviceUtils.h" #include +#define WIN32_LEAN_AND_MEAN +#include + using namespace std; class Ob1Mk4 : public CGenericBase { diff --git a/DeviceAdapters/Hikrobot/HikrobotCamera.h b/DeviceAdapters/Hikrobot/HikrobotCamera.h index 7421a7f14..5b9a94959 100644 --- a/DeviceAdapters/Hikrobot/HikrobotCamera.h +++ b/DeviceAdapters/Hikrobot/HikrobotCamera.h @@ -43,6 +43,9 @@ #include #include "MvCamera.h" +#define WIN32_LEAN_AND_MEAN +#include + ////////////////////////////////////////////////////////////////////////////// // Error codes diff --git a/DeviceAdapters/IntegratedLaserEngine/ILEWrapper/ALC_REVOject3Wrapper.cpp b/DeviceAdapters/IntegratedLaserEngine/ILEWrapper/ALC_REVOject3Wrapper.cpp index 40676c7df..16c9d2701 100644 --- a/DeviceAdapters/IntegratedLaserEngine/ILEWrapper/ALC_REVOject3Wrapper.cpp +++ b/DeviceAdapters/IntegratedLaserEngine/ILEWrapper/ALC_REVOject3Wrapper.cpp @@ -4,8 +4,9 @@ // SUBSYSTEM: DeviceAdapters //----------------------------------------------------------------------------- -#ifdef WIN32 -#include +#ifdef _WIN32 +#define WIN32_LEAN_AND_MEAN +#include #endif #include "ALC_REVOject3Wrapper.h" diff --git a/DeviceAdapters/IntegratedLaserEngine/ILEWrapper/ALC_REV_ILE2Wrapper.cpp b/DeviceAdapters/IntegratedLaserEngine/ILEWrapper/ALC_REV_ILE2Wrapper.cpp index 4cd6bf130..499a2e443 100644 --- a/DeviceAdapters/IntegratedLaserEngine/ILEWrapper/ALC_REV_ILE2Wrapper.cpp +++ b/DeviceAdapters/IntegratedLaserEngine/ILEWrapper/ALC_REV_ILE2Wrapper.cpp @@ -3,8 +3,9 @@ // PROJECT: Micro-Manager // SUBSYSTEM: DeviceAdapters //----------------------------------------------------------------------------- -#ifdef WIN32 -#include +#ifdef _WIN32 +#define WIN32_LEAN_AND_MEAN +#include #endif #include "ALC_REV_ILE2Wrapper.h" #include "ILESDKLock.h" diff --git a/DeviceAdapters/IntegratedLaserEngine/ILEWrapper/ALC_REV_ILE4Wrapper.cpp b/DeviceAdapters/IntegratedLaserEngine/ILEWrapper/ALC_REV_ILE4Wrapper.cpp index 142f912a3..f3a9ecb36 100644 --- a/DeviceAdapters/IntegratedLaserEngine/ILEWrapper/ALC_REV_ILE4Wrapper.cpp +++ b/DeviceAdapters/IntegratedLaserEngine/ILEWrapper/ALC_REV_ILE4Wrapper.cpp @@ -3,8 +3,9 @@ // PROJECT: Micro-Manager // SUBSYSTEM: DeviceAdapters //----------------------------------------------------------------------------- -#ifdef WIN32 -#include +#ifdef _WIN32 +#define WIN32_LEAN_AND_MEAN +#include #endif #include "ALC_REV_ILE4Wrapper.h" #include "ILESDKLock.h" diff --git a/DeviceAdapters/IntegratedLaserEngine/ILEWrapper/ILEWrapper.cpp b/DeviceAdapters/IntegratedLaserEngine/ILEWrapper/ILEWrapper.cpp index 1889a27e2..85396f7f3 100644 --- a/DeviceAdapters/IntegratedLaserEngine/ILEWrapper/ILEWrapper.cpp +++ b/DeviceAdapters/IntegratedLaserEngine/ILEWrapper/ILEWrapper.cpp @@ -8,8 +8,9 @@ // Based off the AndorLaserCombiner adapter from Karl Hoover, UCSF // -#ifdef WIN32 -#include +#ifdef _WIN32 +#define WIN32_LEAN_AND_MEAN +#include #endif #include "ALC_REV.h" @@ -22,7 +23,7 @@ #include "ALC_REV_ILE4Wrapper.h" #include "ILESDKLock.h" #include "../IntegratedLaserEngine.h" -#include "../../../MMDevice/DeviceThreads.h" +#include "DeviceThreads.h" #include #include diff --git a/DeviceAdapters/IntegratedLaserEngine/ILEWrapper/ILEWrapper.h b/DeviceAdapters/IntegratedLaserEngine/ILEWrapper/ILEWrapper.h index cd9f7a4a9..2eb73987e 100644 --- a/DeviceAdapters/IntegratedLaserEngine/ILEWrapper/ILEWrapper.h +++ b/DeviceAdapters/IntegratedLaserEngine/ILEWrapper/ILEWrapper.h @@ -15,6 +15,9 @@ #include "..\ILEWrapperInterface.h" #include +#define WIN32_LEAN_AND_MEAN +#include + class CALC_REV_ILEActiveBlankingManagementWrapper; class CALC_REV_ILEPowerManagementWrapper; class CALC_REV_ILEPowerManagement2Wrapper; diff --git a/DeviceAdapters/IntegratedLaserEngine/IntegratedLaserEngine.cpp b/DeviceAdapters/IntegratedLaserEngine/IntegratedLaserEngine.cpp index ff92587c8..e7b8f6c54 100644 --- a/DeviceAdapters/IntegratedLaserEngine/IntegratedLaserEngine.cpp +++ b/DeviceAdapters/IntegratedLaserEngine/IntegratedLaserEngine.cpp @@ -15,6 +15,7 @@ #include "ILEWrapper/ILEWrapper.h" #include "Lasers.h" #include "VeryLowPower.h" +#include "MMDevice.h" // Properties @@ -619,7 +620,7 @@ void CIntegratedLaserEngine::LogMMMessage( std::string Message, bool DebugOnly ) LogMessage( Message, DebugOnly ); } -MM::MMTime CIntegratedLaserEngine::GetCurrentTime() +MM::MMTime CIntegratedLaserEngine::GetCurrentTimeMM() { return GetCurrentMMTime(); } diff --git a/DeviceAdapters/IntegratedLaserEngine/IntegratedLaserEngine.h b/DeviceAdapters/IntegratedLaserEngine/IntegratedLaserEngine.h index 4f52ef815..20f34c7e5 100644 --- a/DeviceAdapters/IntegratedLaserEngine/IntegratedLaserEngine.h +++ b/DeviceAdapters/IntegratedLaserEngine/IntegratedLaserEngine.h @@ -12,7 +12,7 @@ #ifndef _INTEGRATEDLASERENGINE_H_ #define _INTEGRATEDLASERENGINE_H_ -#include "../../MMDevice/DeviceBase.h" +#include "DeviceBase.h" #include #include #include "ILEWrapperInterface.h" @@ -85,7 +85,7 @@ class CIntegratedLaserEngine : public CShutterBase // Helper functions void LogMMMessage( std::string Message, bool DebugOnly = false ); - MM::MMTime GetCurrentTime(); + MM::MMTime GetCurrentTimeMM(); void CheckAndUpdateLasers(); virtual void CheckAndUpdateLowPowerMode() = 0; diff --git a/DeviceAdapters/IntegratedLaserEngine/Lasers.cpp b/DeviceAdapters/IntegratedLaserEngine/Lasers.cpp index 1adf1cfe8..39d8e654a 100644 --- a/DeviceAdapters/IntegratedLaserEngine/Lasers.cpp +++ b/DeviceAdapters/IntegratedLaserEngine/Lasers.cpp @@ -80,7 +80,7 @@ void CLasers::WaitOnLaserWarmingUp() std::vector vState( NumberOfLasers_ + 1, ALC_NOT_AVAILABLE ); // Lasers can take up to 90 seconds to initialize - MM::TimeoutMs vTimerOut( MMILE_->GetCurrentTime(), 91000 ); + MM::TimeoutMs vTimerOut( MMILE_->GetCurrentTimeMM(), 91000 ); while ( true ) { @@ -119,7 +119,7 @@ void CLasers::WaitOnLaserWarmingUp() break; } - if ( vTimerOut.expired( MMILE_->GetCurrentTime() ) ) + if ( vTimerOut.expired( MMILE_->GetCurrentTimeMM() ) ) { MMILE_->LogMMMessage( " some lasers did not respond", false ); break; diff --git a/DeviceAdapters/IntegratedLaserEngine/Lasers.h b/DeviceAdapters/IntegratedLaserEngine/Lasers.h index 812771cb4..4486f5c7e 100644 --- a/DeviceAdapters/IntegratedLaserEngine/Lasers.h +++ b/DeviceAdapters/IntegratedLaserEngine/Lasers.h @@ -13,7 +13,10 @@ #define _LASERS_H_ #include "Property.h" -#include "../../MMDevice/DeviceThreads.h" +#include "DeviceThreads.h" + +#define WIN32_LEAN_AND_MEAN +#include class IALC_REV_Laser2; class IALC_REV_ILEPowerManagement; diff --git a/DeviceAdapters/IntegratedLaserEngine/PortsConfiguration.cpp b/DeviceAdapters/IntegratedLaserEngine/PortsConfiguration.cpp index 4506ea49f..756f1015c 100644 --- a/DeviceAdapters/IntegratedLaserEngine/PortsConfiguration.cpp +++ b/DeviceAdapters/IntegratedLaserEngine/PortsConfiguration.cpp @@ -6,7 +6,8 @@ #include "PortsConfiguration.h" #include "IntegratedLaserEngine.h" -#include +#define WIN32_LEAN_AND_MEAN +#include #include #include #include "boost\filesystem.hpp" diff --git a/DeviceAdapters/JAI/JAI.h b/DeviceAdapters/JAI/JAI.h index d6c616138..d969f0012 100644 --- a/DeviceAdapters/JAI/JAI.h +++ b/DeviceAdapters/JAI/JAI.h @@ -26,17 +26,8 @@ #include #include -#ifdef WIN32 -//... -#endif - -#ifdef __APPLE__ -//... -#endif - -#ifdef __linux__ -//... -#endif +#define WIN32_LEAN_AND_MEAN +#include #include #include diff --git a/DeviceAdapters/LaserQuantumLaser/LaserQuantumLaser.cpp b/DeviceAdapters/LaserQuantumLaser/LaserQuantumLaser.cpp index a6914d7ba..6e02bf84a 100644 --- a/DeviceAdapters/LaserQuantumLaser/LaserQuantumLaser.cpp +++ b/DeviceAdapters/LaserQuantumLaser/LaserQuantumLaser.cpp @@ -13,8 +13,9 @@ #include #include -#ifdef WIN32 -#include "winuser.h" +#ifdef _WIN32 +#define WIN32_LEAN_AND_MEAN +#include #endif const char* g_DeviceName = "Laser"; diff --git a/DeviceAdapters/MCCDAQ/MCCDAQ.cpp b/DeviceAdapters/MCCDAQ/MCCDAQ.cpp index 8c8634dba..e7814652f 100644 --- a/DeviceAdapters/MCCDAQ/MCCDAQ.cpp +++ b/DeviceAdapters/MCCDAQ/MCCDAQ.cpp @@ -21,7 +21,10 @@ #include "MCCDAQ.h" #include "ModuleInterface.h" + +#define WIN32_LEAN_AND_MEAN #include "cbw.h" + #include diff --git a/DeviceAdapters/MCL_MicroDrive/MicroDriveXYStage.h b/DeviceAdapters/MCL_MicroDrive/MicroDriveXYStage.h index 43d364817..dd09878d3 100644 --- a/DeviceAdapters/MCL_MicroDrive/MicroDriveXYStage.h +++ b/DeviceAdapters/MCL_MicroDrive/MicroDriveXYStage.h @@ -20,6 +20,9 @@ License: Distributed under the BSD license. #include "handle_list_if.h" #include "HandleListType.h" +#define WIN32_LEAN_AND_MEAN +#include + #define ERR_UNKNOWN_MODE 102 #define ERR_UNKNOWN_POSITION 103 #define ERR_NOT_VALID_INPUT 104 diff --git a/DeviceAdapters/MCL_MicroDrive/MicroDriveZStage.h b/DeviceAdapters/MCL_MicroDrive/MicroDriveZStage.h index 93628438d..5db6a05de 100644 --- a/DeviceAdapters/MCL_MicroDrive/MicroDriveZStage.h +++ b/DeviceAdapters/MCL_MicroDrive/MicroDriveZStage.h @@ -19,6 +19,9 @@ License: Distributed under the BSD license. #include "handle_list_if.h" #include "HandleListType.h" +#define WIN32_LEAN_AND_MEAN +#include + #define ERR_UNKNOWN_MODE 102 #define ERR_UNKNOWN_POSITION 103 #define ERR_NOT_VALID_INPUT 104 diff --git a/DeviceAdapters/MCL_NanoDrive/MCL_NanoDrive_XYStage.cpp b/DeviceAdapters/MCL_NanoDrive/MCL_NanoDrive_XYStage.cpp index 310832435..d5c29a2dc 100644 --- a/DeviceAdapters/MCL_NanoDrive/MCL_NanoDrive_XYStage.cpp +++ b/DeviceAdapters/MCL_NanoDrive/MCL_NanoDrive_XYStage.cpp @@ -9,6 +9,9 @@ License: Distributed under the BSD license. #include #include +#define WIN32_LEAN_AND_MEAN +#include + MCL_NanoDrive_XYStage::MCL_NanoDrive_XYStage(): calibrationX_(0), calibrationY_(0), diff --git a/DeviceAdapters/MCL_NanoDrive/MCL_NanoDrive_ZStage.cpp b/DeviceAdapters/MCL_NanoDrive/MCL_NanoDrive_ZStage.cpp index b63bdb6fa..52b400170 100644 --- a/DeviceAdapters/MCL_NanoDrive/MCL_NanoDrive_ZStage.cpp +++ b/DeviceAdapters/MCL_NanoDrive/MCL_NanoDrive_ZStage.cpp @@ -9,6 +9,9 @@ License: Distributed under the BSD license. #include #include +#define WIN32_LEAN_AND_MEAN +#include + MCL_NanoDrive_ZStage::MCL_NanoDrive_ZStage() : axis_(0), calibration_(0.0), diff --git a/DeviceAdapters/Mightex_C_Cam/Mightex_USBCamera.h b/DeviceAdapters/Mightex_C_Cam/Mightex_USBCamera.h index f58390a65..1afc1af84 100755 --- a/DeviceAdapters/Mightex_C_Cam/Mightex_USBCamera.h +++ b/DeviceAdapters/Mightex_C_Cam/Mightex_USBCamera.h @@ -35,6 +35,9 @@ #include #include +#define WIN32_LEAN_AND_MEAN +#include + ////////////////////////////////////////////////////////////////////////////// // Error codes // diff --git a/DeviceAdapters/Mightex_SB_Cam/Mightex_SB_Camera.h b/DeviceAdapters/Mightex_SB_Cam/Mightex_SB_Camera.h index 0ed46bae2..85a73cdb0 100644 --- a/DeviceAdapters/Mightex_SB_Cam/Mightex_SB_Camera.h +++ b/DeviceAdapters/Mightex_SB_Cam/Mightex_SB_Camera.h @@ -35,6 +35,9 @@ #include #include +#define WIN32_LEAN_AND_MEAN +#include + ////////////////////////////////////////////////////////////////////////////// // Error codes // diff --git a/DeviceAdapters/Motic/MoticCamera.h b/DeviceAdapters/Motic/MoticCamera.h index d240f32d9..cdb3842ea 100644 --- a/DeviceAdapters/Motic/MoticCamera.h +++ b/DeviceAdapters/Motic/MoticCamera.h @@ -35,6 +35,10 @@ #include "ImgBuffer.h" #include "DeviceThreads.h" #include "ImgBuffer.h" + +#define WIN32_LEAN_AND_MEAN +#include + using namespace std; ////////////////////////////////////////////////////////////////////////////// // Error codes diff --git a/DeviceAdapters/MoticMicroscope/MoticMicroscope.h b/DeviceAdapters/MoticMicroscope/MoticMicroscope.h index 5875b773c..b4064b265 100644 --- a/DeviceAdapters/MoticMicroscope/MoticMicroscope.h +++ b/DeviceAdapters/MoticMicroscope/MoticMicroscope.h @@ -32,9 +32,13 @@ #include #include -using namespace std; #include "DeviceBase.h" +#define WIN32_LEAN_AND_MEAN +#include + +using namespace std; + // Error codes #define ERR_HUB_PATH (900) diff --git a/DeviceAdapters/Okolab/OkolabDevice.cpp b/DeviceAdapters/Okolab/OkolabDevice.cpp index 7f63c0c65..e02d78a75 100644 --- a/DeviceAdapters/Okolab/OkolabDevice.cpp +++ b/DeviceAdapters/Okolab/OkolabDevice.cpp @@ -3,6 +3,9 @@ #include #include +#define WIN32_LEAN_AND_MEAN +#include + /* String constants */ std::vector OkolabDevice::_ports; bool OkolabDevice::_initialized = false; diff --git a/DeviceAdapters/Omicron/Omicron.cpp b/DeviceAdapters/Omicron/Omicron.cpp index 5a8558568..b3e799570 100644 --- a/DeviceAdapters/Omicron/Omicron.cpp +++ b/DeviceAdapters/Omicron/Omicron.cpp @@ -11,8 +11,9 @@ #include "Omicron.h" -#ifdef _WINDOWS -#include "winuser.h" +#ifdef _WIN32 +#define WIN32_LEAN_AND_MEAN +#include #endif const char* g_DeviceoldOmicronName = "Omicron"; diff --git a/DeviceAdapters/Omicron/OmicronxX.cpp b/DeviceAdapters/Omicron/OmicronxX.cpp index 75a2e4522..ad01d275a 100644 --- a/DeviceAdapters/Omicron/OmicronxX.cpp +++ b/DeviceAdapters/Omicron/OmicronxX.cpp @@ -13,10 +13,12 @@ #include "Omicron.h" #include "CoherentOBISDirect.h" -#ifdef _WINDOWS +#ifdef _WIN32 #include "OmicronDeviceDriver.h" #include "OmicronxXDevices.h" #define OMICRON_XDEVICES +#define WIN32_LEAN_AND_MEAN +#include #endif #include diff --git a/DeviceAdapters/OxxiusCombiner/OxxiusCombinerHub.h b/DeviceAdapters/OxxiusCombiner/OxxiusCombinerHub.h index 117001914..6f1229726 100644 --- a/DeviceAdapters/OxxiusCombiner/OxxiusCombinerHub.h +++ b/DeviceAdapters/OxxiusCombiner/OxxiusCombinerHub.h @@ -13,8 +13,9 @@ using namespace std; //For Obis -#ifdef WIN32 - #include +#ifdef _WIN32 + #define WIN32_LEAN_AND_MEAN + #include #endif #include "DeviceUtils.h" #include diff --git a/DeviceAdapters/PCO_Generic/MicroManager.cpp b/DeviceAdapters/PCO_Generic/MicroManager.cpp index cd34376a4..9de968178 100644 --- a/DeviceAdapters/PCO_Generic/MicroManager.cpp +++ b/DeviceAdapters/PCO_Generic/MicroManager.cpp @@ -19,12 +19,14 @@ // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES. // -#include "..\..\MMDevice/ModuleInterface.h" +#include "MicroManager.h" + +#include "ModuleInterface.h" + #define PCO_ERRT_H_CREATE_OBJECT #include "PCO_err.h" #include "PCO_errt.h" -#include "MicroManager.h" #include "VersionNo.h" #if defined _WIN64 diff --git a/DeviceAdapters/PCO_Generic/MicroManager.h b/DeviceAdapters/PCO_Generic/MicroManager.h index 5eab756ff..10e83a6a7 100644 --- a/DeviceAdapters/PCO_Generic/MicroManager.h +++ b/DeviceAdapters/PCO_Generic/MicroManager.h @@ -24,10 +24,14 @@ #ifndef _PCO_GENERIC_H_ #define _PCO_GENERIC_H_ -#include "../../MMDevice/DeviceBase.h" -#include "../../MMDevice/ImgBuffer.h" -#include "../../MMDevice/DeviceThreads.h" -#include "../../MMDevice/DeviceUtils.h" +#include "DeviceBase.h" +#include "ImgBuffer.h" +#include "DeviceThreads.h" +#include "DeviceUtils.h" + +#define WIN32_LEAN_AND_MEAN +#include + #include "Camera.h" #include #include diff --git a/DeviceAdapters/PICAM/PICAMAdapter.h b/DeviceAdapters/PICAM/PICAMAdapter.h index 062e1aab0..ef9f94e12 100644 --- a/DeviceAdapters/PICAM/PICAMAdapter.h +++ b/DeviceAdapters/PICAM/PICAMAdapter.h @@ -32,11 +32,13 @@ #include "DeviceUtils.h" #include "DeviceThreads.h" -#ifdef WIN64 +#ifdef _WIN32 #pragma warning(push) #include "picam.h" #include "picam_advanced.h" #pragma warning(pop) +#define WIN32_LEAN_AND_MEAN +#include #endif #include // for mem_fn diff --git a/DeviceAdapters/PI_GCS_2/PIController.cpp b/DeviceAdapters/PI_GCS_2/PIController.cpp index b557b811d..4df6abf6a 100644 --- a/DeviceAdapters/PI_GCS_2/PIController.cpp +++ b/DeviceAdapters/PI_GCS_2/PIController.cpp @@ -27,6 +27,11 @@ #include "PIGCSCommands.h" #include "PI_GCS_2.h" +#ifdef _WIN32 +#define WIN32_LEAN_AND_MEAN +#include +#endif + std::map PIController::allControllersByLabel_; PIController::PIController (const std::string& label, MM::Core* logsink, MM::Device* logdevice) diff --git a/DeviceAdapters/PI_GCS_2/PIGCSCommands.cpp b/DeviceAdapters/PI_GCS_2/PIGCSCommands.cpp index 3ba9b3dc0..2355454b1 100644 --- a/DeviceAdapters/PI_GCS_2/PIGCSCommands.cpp +++ b/DeviceAdapters/PI_GCS_2/PIGCSCommands.cpp @@ -26,6 +26,11 @@ #include "PI_GCS_2.h" #include "PIController.h" // error codes +#ifdef _WIN32 +#define WIN32_LEAN_AND_MEAN +#include +#endif + PIGCSCommands::PIGCSCommands () : controllerError_ (PI_CNTR_NO_ERROR) diff --git a/DeviceAdapters/PI_GCS_2/PIGCSCommandsDLL.h b/DeviceAdapters/PI_GCS_2/PIGCSCommandsDLL.h index 9f9eb5408..cc578d3b3 100644 --- a/DeviceAdapters/PI_GCS_2/PIGCSCommandsDLL.h +++ b/DeviceAdapters/PI_GCS_2/PIGCSCommandsDLL.h @@ -30,6 +30,11 @@ #include #include +#ifdef _WIN32 +#define WIN32_LEAN_AND_MEAN +#include +#endif + class PIController; class PIGCSCommandsDLL : public PIGCSCommands @@ -83,7 +88,7 @@ class PIGCSCommandsDLL : public PIGCSCommands std::string dllPrefix_; int ID_; -#ifdef WIN32 +#ifdef _WIN32 HMODULE module_; #else void* module_; diff --git a/DeviceAdapters/PI_GCS_2/PIXYStage.cpp b/DeviceAdapters/PI_GCS_2/PIXYStage.cpp index b75c331ea..bcf3aa577 100644 --- a/DeviceAdapters/PI_GCS_2/PIXYStage.cpp +++ b/DeviceAdapters/PI_GCS_2/PIXYStage.cpp @@ -25,6 +25,11 @@ #include "PIXYStage.h" #include "PIController.h" +#ifdef _WIN32 +#define WIN32_LEAN_AND_MEAN +#include +#endif + const char* PIXYStage::DeviceName_ = "PIXYStage"; const char* g_PI_XYStageAxisXName = "Axis X: Name"; diff --git a/DeviceAdapters/PI_GCS_2/PIZStage.cpp b/DeviceAdapters/PI_GCS_2/PIZStage.cpp index 788355117..c5929a846 100644 --- a/DeviceAdapters/PI_GCS_2/PIZStage.cpp +++ b/DeviceAdapters/PI_GCS_2/PIZStage.cpp @@ -27,6 +27,11 @@ #include "PI_GCS_2.h" #include "PIController.h" +#ifdef _WIN32 +#define WIN32_LEAN_AND_MEAN +#include +#endif + const char* PIZStage::DeviceName_ = "PIZStage"; const char* g_PI_ZStageAxisName = "Axis"; const char* g_PI_ZStageAxisLimitUm = "Limit_um"; diff --git a/DeviceAdapters/PicardStage/PicardStage.cpp b/DeviceAdapters/PicardStage/PicardStage.cpp index 39477f992..6f8aae253 100644 --- a/DeviceAdapters/PicardStage/PicardStage.cpp +++ b/DeviceAdapters/PicardStage/PicardStage.cpp @@ -21,12 +21,16 @@ // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES. -#include +#include "PicardStage.h" #include "ModuleInterface.h" + +#include + +#define WIN32_LEAN_AND_MEAN +#include #include "PiUsb.h" -#include "PicardStage.h" using namespace std; diff --git a/DeviceAdapters/RaptorEPIX/RaptorEPIX.h b/DeviceAdapters/RaptorEPIX/RaptorEPIX.h index 99331202e..b18ca36db 100644 --- a/DeviceAdapters/RaptorEPIX/RaptorEPIX.h +++ b/DeviceAdapters/RaptorEPIX/RaptorEPIX.h @@ -28,6 +28,9 @@ #include "ImgBuffer.h" #include "DeviceThreads.h" +#define WIN32_LEAN_AND_MEAN +#include + //#define PLEORA #ifdef PLEORA diff --git a/DeviceAdapters/SigmaKoki/Camera.h b/DeviceAdapters/SigmaKoki/Camera.h index e4bff73f8..d7c08d841 100644 --- a/DeviceAdapters/SigmaKoki/Camera.h +++ b/DeviceAdapters/SigmaKoki/Camera.h @@ -16,6 +16,10 @@ #include #include #include + +#define WIN32_LEAN_AND_MEAN +#include + using namespace std; extern const char* g_CameraDeviceName; #pragma endregion Prehead_Inclus diff --git a/DeviceAdapters/TSI/TSI3Cam.h b/DeviceAdapters/TSI/TSI3Cam.h index dfbacc302..115bde84e 100644 --- a/DeviceAdapters/TSI/TSI3Cam.h +++ b/DeviceAdapters/TSI/TSI3Cam.h @@ -29,16 +29,9 @@ #include "tl_camera_sdk.h" #include "tl_camera_sdk_load.h" -#ifdef WIN32 -//... -#endif - -#ifdef __APPLE__ -//... -#endif - -#ifdef __linux__ -//... +#ifdef _WIN32 +#define WIN32_LEAN_AND_MEAN +#include #endif #include diff --git a/DeviceAdapters/TSI/TSICam.h b/DeviceAdapters/TSI/TSICam.h index 0c7577756..af27ccf67 100644 --- a/DeviceAdapters/TSI/TSICam.h +++ b/DeviceAdapters/TSI/TSICam.h @@ -31,16 +31,9 @@ #include #include "TsiLibrary.h" -#ifdef WIN32 -//... -#endif - -#ifdef __APPLE__ -//... -#endif - -#ifdef linux -//... +#ifdef _WIN32 +#define WIN32_LEAN_AND_MEAN +#include #endif #include diff --git a/DeviceAdapters/ThorlabsCHROLIS/ThorlabsChrolis.cpp b/DeviceAdapters/ThorlabsCHROLIS/ThorlabsChrolis.cpp index b6b684288..8fcd66fd9 100644 --- a/DeviceAdapters/ThorlabsCHROLIS/ThorlabsChrolis.cpp +++ b/DeviceAdapters/ThorlabsCHROLIS/ThorlabsChrolis.cpp @@ -25,6 +25,9 @@ #include +#define WIN32_LEAN_AND_MEAN +#include + MODULE_API void InitializeModuleData() { RegisterDevice(CHROLIS_HUB_NAME, MM::HubDevice, diff --git a/DeviceAdapters/Toptica_iBeamSmartCW/Toptica_iBeamSmartCW.cpp b/DeviceAdapters/Toptica_iBeamSmartCW/Toptica_iBeamSmartCW.cpp index 52f6e1f4c..d08a19a1d 100644 --- a/DeviceAdapters/Toptica_iBeamSmartCW/Toptica_iBeamSmartCW.cpp +++ b/DeviceAdapters/Toptica_iBeamSmartCW/Toptica_iBeamSmartCW.cpp @@ -12,8 +12,9 @@ #include "Toptica_iBeamSmartCW.h" -#ifdef WIN32 -#include "winuser.h" +#ifdef _WIN32 +#define WIN32_LEAN_AND_MEAN +#include #endif const char* g_DeviceiBeamSmartName = "iBeamSmartCW"; diff --git a/DeviceAdapters/TriggerScope/TriggerScope.cpp b/DeviceAdapters/TriggerScope/TriggerScope.cpp index f171e19d2..931653a1a 100644 --- a/DeviceAdapters/TriggerScope/TriggerScope.cpp +++ b/DeviceAdapters/TriggerScope/TriggerScope.cpp @@ -26,7 +26,10 @@ #include "ModuleInterface.h" -#ifndef _WIN32 +#ifdef _WIN32 +#define WIN32_LEAN_AND_MEAN +#include +#else #include #endif @@ -65,26 +68,6 @@ const char* g_Off = "Off"; // static lock MMThreadLock CTriggerScopeHub::lock_; -// TODO: linux entry code - -// windows DLL entry code -#ifdef WIN32 -BOOL APIENTRY DllMain( HANDLE /*hModule*/, - DWORD ul_reason_for_call, - LPVOID /*lpReserved*/ - ) -{ - switch (ul_reason_for_call) - { - case DLL_PROCESS_ATTACH: - case DLL_THREAD_ATTACH: - case DLL_THREAD_DETACH: - case DLL_PROCESS_DETACH: - break; - } - return TRUE; -} -#endif /////////////////////////////////////////////////////////////////////////////// // Exported MMDevice API diff --git a/DeviceAdapters/TriggerScope/TriggerScope.h b/DeviceAdapters/TriggerScope/TriggerScope.h index fe2cdbe8d..faa40b9da 100644 --- a/DeviceAdapters/TriggerScope/TriggerScope.h +++ b/DeviceAdapters/TriggerScope/TriggerScope.h @@ -27,7 +27,6 @@ #define _TriggerScope_H_ #include "DeviceBase.h" -#include "../Utilities/Utilities.h" #include #include #include diff --git a/DeviceAdapters/TriggerScopeMM/TriggerScopeMM.cpp b/DeviceAdapters/TriggerScopeMM/TriggerScopeMM.cpp index 0a9d5ba15..1f123b2f6 100644 --- a/DeviceAdapters/TriggerScopeMM/TriggerScopeMM.cpp +++ b/DeviceAdapters/TriggerScopeMM/TriggerScopeMM.cpp @@ -29,7 +29,6 @@ #include #include #include "ModuleInterface.h" -#include "../../MMCore/Error.h" #include #include #include @@ -59,26 +58,6 @@ const char * g_TriggerScope_Version = "v1.0-MM, 8/24/2020"; // static lock MMThreadLock CTriggerScopeMMHub::lock_; -// TODO: linux entry code - -// windows DLL entry code -#ifdef WIN32 -BOOL APIENTRY DllMain( HANDLE /*hModule*/, - DWORD ul_reason_for_call, - LPVOID /*lpReserved*/ - ) -{ - switch (ul_reason_for_call) - { - case DLL_PROCESS_ATTACH: - case DLL_THREAD_ATTACH: - case DLL_THREAD_DETACH: - case DLL_PROCESS_DETACH: - break; - } - return TRUE; -} -#endif /////////////////////////////////////////////////////////////////////////////// // Exported MMDevice API diff --git a/DeviceAdapters/USB_Viper_QPL/XCiteViper.cpp b/DeviceAdapters/USB_Viper_QPL/XCiteViper.cpp index 8e32b2482..4b7889f4f 100644 --- a/DeviceAdapters/USB_Viper_QPL/XCiteViper.cpp +++ b/DeviceAdapters/USB_Viper_QPL/XCiteViper.cpp @@ -14,9 +14,10 @@ #include "XCiteViper.h" #include "ModuleInterface.h" -#include "cbw.h" #include +#define WIN32_LEAN_AND_MEAN +#include "cbw.h" const int BOARDREADY = 100; diff --git a/DeviceAdapters/UniversalMMHubSerial/ummhSerial.cpp b/DeviceAdapters/UniversalMMHubSerial/ummhSerial.cpp index c1ef20c59..cb843dc7a 100644 --- a/DeviceAdapters/UniversalMMHubSerial/ummhSerial.cpp +++ b/DeviceAdapters/UniversalMMHubSerial/ummhSerial.cpp @@ -24,6 +24,9 @@ #include "ummhSerial.h" #include "ummhreserved.h" +#define WIN32_LEAN_AND_MEAN +#include + using namespace std; // External names used by the rest of the system diff --git a/DeviceAdapters/UniversalMMHubUsb/ummhUsb.cpp b/DeviceAdapters/UniversalMMHubUsb/ummhUsb.cpp index 3d8e256bb..d0f17e56c 100644 --- a/DeviceAdapters/UniversalMMHubUsb/ummhUsb.cpp +++ b/DeviceAdapters/UniversalMMHubUsb/ummhUsb.cpp @@ -28,10 +28,13 @@ #include "ummhUsb.h" #include "../UniversalMMHubSerial/ummhreserved.h" -#include "libusb.h" #include "CameraImageMetadata.h" +#define WIN32_LEAN_AND_MEAN +#include +#include "libusb.h" + using namespace MM; // External names used by the rest of the system diff --git a/DeviceAdapters/VisiTech_iSIM/VTiSIM.h b/DeviceAdapters/VisiTech_iSIM/VTiSIM.h index 6e6912934..7a76e6d25 100644 --- a/DeviceAdapters/VisiTech_iSIM/VTiSIM.h +++ b/DeviceAdapters/VisiTech_iSIM/VTiSIM.h @@ -35,6 +35,9 @@ #include "DeviceBase.h" +#define WIN32_LEAN_AND_MEAN +#include + class VTiSIMHub : public HubBase { diff --git a/DeviceAdapters/Vortran/VersaLase.cpp b/DeviceAdapters/Vortran/VersaLase.cpp index 397af8c5a..f1cea175d 100644 --- a/DeviceAdapters/Vortran/VersaLase.cpp +++ b/DeviceAdapters/Vortran/VersaLase.cpp @@ -48,8 +48,9 @@ */ #include "VersaLase.h" -#ifdef WIN32 - #include +#ifdef _WIN32 + #define WIN32_LEAN_AND_MEAN + #include #endif #include "MMDevice.h" diff --git a/DeviceAdapters/ZWO/MyASICam2.cpp b/DeviceAdapters/ZWO/MyASICam2.cpp index 58efb3508..fb54f59f7 100644 --- a/DeviceAdapters/ZWO/MyASICam2.cpp +++ b/DeviceAdapters/ZWO/MyASICam2.cpp @@ -1,7 +1,3 @@ -#include "MyASICam2.h" - -#include "CameraImageMetadata.h" - /////////////////////////////////////////////////////////////////////////////// // FILE: CMyASICam.cpp // PROJECT: Micro-Manager @@ -26,6 +22,12 @@ // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES. // +#include "MyASICam2.h" + +#include "CameraImageMetadata.h" + +#define WIN32_LEAN_AND_MEAN +#include using namespace std; diff --git a/MMDevice/DeviceThreads.h b/MMDevice/DeviceThreads.h index 710f8dd70..9fdebc57a 100644 --- a/MMDevice/DeviceThreads.h +++ b/MMDevice/DeviceThreads.h @@ -20,133 +20,104 @@ #pragma once -#ifdef _WIN32 - #define WIN32_LEAN_AND_MEAN - #include -#else - #include -#endif +#include +#include /** * @brief Base class for threads in MM devices. + * + * @attention New code should use std::thread instead. */ class MMDeviceThreadBase { public: - MMDeviceThreadBase() : thread_(0) {} - virtual ~MMDeviceThreadBase() {} + MMDeviceThreadBase() {} + virtual ~MMDeviceThreadBase() + { + // Detaching on destruction may not be the ideal design, but the only one + // possible given previous behavior (which leaked the native handle). + if (thread_.joinable()) + thread_.detach(); + } + + // Cannot copy a thread + MMDeviceThreadBase(const MMDeviceThreadBase&) = delete; + MMDeviceThreadBase& operator=(const MMDeviceThreadBase&) = delete; + + // We also cannot safely support move because the thread calls svc() by + // reference. + MMDeviceThreadBase(MMDeviceThreadBase&&) = delete; + MMDeviceThreadBase& operator=(MMDeviceThreadBase&&) = delete; + + /** + * @brief This function is called on the new thread. + * + * The return value is ignored. + */ virtual int svc() = 0; - virtual int activate() + void activate() { -#ifdef _WIN32 - DWORD id; - thread_ = CreateThread(NULL, 0, ThreadProc, this, 0, &id); -#else - pthread_create(&thread_, NULL, ThreadProc, this); -#endif - return 0; // TODO: return thread id + if (thread_.joinable()) + thread_.detach(); + thread_ = std::thread([this]() { (void)svc(); }); + // Note: failure to create the thread will throw std::system_error, but + // that only happens upon resource exhaustion (normally rare; akin to + // std::bad_alloc). Most callers do not handle this, but terminating with + // an uncaught exception is preferable to silently continuing (as we + // previously did). } void wait() { -#ifdef _WIN32 - WaitForSingleObject(thread_, INFINITE); -#else - pthread_join(thread_, NULL); -#endif + // Note: joining a non-joinable thread (a programming error) will throw + // std::system_error. + thread_.join(); } private: - // Forbid copying - MMDeviceThreadBase(const MMDeviceThreadBase&); - MMDeviceThreadBase& operator=(const MMDeviceThreadBase&); - -#ifdef _WIN32 - HANDLE -#else - pthread_t -#endif - thread_; - - static -#ifdef _WIN32 - DWORD WINAPI -#else - void* -#endif - ThreadProc(void* param) - { - MMDeviceThreadBase* pThrObj = (MMDeviceThreadBase*) param; -#ifdef _WIN32 - return pThrObj->svc(); -#else - pThrObj->svc(); - return (void*) 0; -#endif - } + std::thread thread_; }; /** * @brief Critical section lock. + * + * @attention New code should use std::mutex or std::recursive_mutex instead + * (note that MMThreadLock is recursive). */ class MMThreadLock { public: - MMThreadLock() - { -#ifdef _WIN32 - InitializeCriticalSection(&lock_); -#else - pthread_mutexattr_t a; - pthread_mutexattr_init(&a); - pthread_mutexattr_settype(&a, PTHREAD_MUTEX_RECURSIVE); - pthread_mutex_init(&lock_, &a); - pthread_mutexattr_destroy(&a); -#endif - } + MMThreadLock() = default; - ~MMThreadLock() - { -#ifdef _WIN32 - DeleteCriticalSection(&lock_); -#else - pthread_mutex_destroy(&lock_); -#endif - } + // Disallow moving because we always did and no reason to newly allow. + ~MMThreadLock() = default; + MMThreadLock(const MMThreadLock&) = delete; + MMThreadLock& operator=(const MMThreadLock&) = delete; + MMThreadLock(MMThreadLock&&) = delete; + MMThreadLock& operator=(MMThreadLock&&) = delete; void Lock() { -#ifdef _WIN32 - EnterCriticalSection(&lock_); -#else - pthread_mutex_lock(&lock_); -#endif + mutex_.lock(); } void Unlock() { -#ifdef _WIN32 - LeaveCriticalSection(&lock_); -#else - pthread_mutex_unlock(&lock_); -#endif + mutex_.unlock(); } private: - // Forbid copying - MMThreadLock(const MMThreadLock&); - MMThreadLock& operator=(const MMThreadLock&); - -#ifdef _WIN32 - CRITICAL_SECTION -#else - pthread_mutex_t -#endif - lock_; + std::recursive_mutex mutex_; }; + +/** + * @brief RAII object to acquire and auto-release MMThreadLock. + * + * @attention New code should use std::lock_guard instead. + */ class MMThreadGuard { public: @@ -157,22 +128,21 @@ class MMThreadGuard MMThreadGuard(MMThreadLock* lock) : lock_(lock) { - if (lock != 0) + if (lock != nullptr) lock_->Lock(); } - bool isLocked() {return lock_ == 0 ? false : true;} - ~MMThreadGuard() { - if (lock_ != 0) + if (lock_ != nullptr) lock_->Unlock(); } -private: - // Forbid copying - MMThreadGuard(const MMThreadGuard&); - MMThreadGuard& operator=(const MMThreadGuard&); + MMThreadGuard(const MMThreadGuard&) = delete; + MMThreadGuard& operator=(const MMThreadGuard&) = delete; + MMThreadGuard(MMThreadGuard&&) = delete; + MMThreadGuard& operator=(MMThreadGuard&&) = delete; +private: MMThreadLock* lock_; };