Closed mikechiarappa closed 2 years ago
Hey could you send the build log. I can build correctly with VS2019 and VS2022
Here it is:
Rebuild started...
1>------ Rebuild All started: Project: WinBleLib, Configuration: Debug Win32 ------
1>BleDevice.cpp
1>BleDeviceContext.cpp
1>BleDeviceEnumerator.cpp
1>BleDeviceInfo.cpp
1>BleException.cpp
1>BleFunctions.cpp
1>BleGattCharacteristic.cpp
1>BleGattCharacteristicValue.cpp
1>BleGattDescriptor.cpp
1>BleGattDescriptorValue.cpp
1>BleGattNotificationData.cpp
1>BleGattService.cpp
1>CallbackContext.cpp
1>HandleWrapper.cpp
1>Utility.cpp
1>Generating Code...
1>WinBleLib.vcxproj -> C:\Users\m.chiarappa\source\repos\WinBle-master\src\Debug\WinBleLib.lib
2>------ Rebuild All started: Project: WinBleTest, Configuration: Debug Win32 ------
2>WinBleTest.cpp
2>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629\include\xmemory(682,47): error C2280: 'std::unique_ptr<BleGattService,std::default_delete
If I try to compile the code for x64 the result is the same. I left untouched the code.
Its an odd one as it is due to the fact that the unique_ptr cannot be copied as it has unique ownership properties.
When targeting Visual Studio 2019 (v142) the code compiles. When targeting Visual Studio 2022 (v143) the code does not compile as it enforces the no copy semantics of the unique_ptr. I am not sure why this is the case as the definition of the unique_ptr is the same in both so it should have broken when I used unique_ptr in the first place. It looks like some compiler differences.
unique_ptr(const unique_ptr&) = delete;
unique_ptr& operator=(const unique_ptr&) = delete;
The simplest solution is to use shared_ptr over unique_ptr as the ownership semantics are not that important or change the coded to use move operations.
I can update the code to use share_ptr but not right now. Maybe in a day or too.
Hi Derek, I would inform you I have textually replaced all instances on unique_ptr with shared_ptr and now the code is compiled correctly.
Hi Mike,
If you like maybe you could open a PR and I can merge the changes into dev branch. If not I can make the changes later today and push to dev
I've just applied my patches on PR (I hope I haven't made mistakes: 4 files patched) Bye
I have merged the PR and have also updated the platform tool set to VS2022 and replaced the remaining unique_ptr references
Hi, I'm able to partialy compile the project using VS2022 Community: subproject WinBleLib compiles fine, but WinBleTest gives me error C2280. The project fork David-Sackstein/WinBle compiles correctly. The issue seems related to the adoption of.
Do you have some suggestion or hint about ?
Thx in advance