reactphysics3d
reactphysics3d copied to clipboard
Build warnings and errors on UWP
When building 0.9.0 on UWP, there's some additional warnings and errors that surface! I am currently trying to switch from calling msbuild directly on Windows (which did work) to calling cmake instead, so I suspect these popped up now for me because of some different flags in use between the two.
This error pops up in a dozen or so locations, this one should be possible for me to avoid with some arcane cmake, but would be nice if I didn't have to.
C:\Temp\StereoKitBuild\reactphysics3d\include\reactphysics3d/utils/DefaultLogger.h(109,58): error C4996: 'localtime': This function or variable may be unsafe. Consider using localtime_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. (compiling source file C:\Temp\StereoKitBuild\reactphysics3d\src\utils\DefaultLogger.cpp) [C:\Temp\StereoKitBuild\reactphysics3d\build_x64_UWP_Release\reactphysics3d.vcxproj ]
And then there's these two errors, which I didn't trace too far, but could be valid complaints.
C:\Temp\StereoKitBuild\reactphysics3d\src\systems\CollisionDetectionSystem.cpp(537): error C4703: potentially uninitialized local pointer variable 'shape1' used [C:\Temp\StereoKitBuild\reactphysics3d\build_x64_UWP_Release\reactphysics3d.vcxproj]
C:\Temp\StereoKitBuild\reactphysics3d\src\systems\CollisionDetectionSystem.cpp(537): error C4703: potentially uninitialized local pointer variable 'shape2' used [C:\Temp\StereoKitBuild\reactphysics3d\build_x64_UWP_Release\reactphysics3d.vcxproj]
This warning also pops up a dozen times or so in different places. It does mention a pretty specific solution, but I'm still trying to wrap my head around it, so I'm just sharing it here for completeness.
C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.32.31326\include\ostream(770,1): warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc (compiling source file C:\Temp\StereoKitBuild\reactphysics3d\src\utils\DefaultLogger.cpp) [C:\Temp\StereoKitBuild\reactphysics3d\build_x64_UWP_Release\reactphysics3d.vcxproj]
C:\Temp\StereoKitBuild\reactphysics3d\include\reactphysics3d/utils/DefaultLogger.h(107): message : see reference to function template instantiation 'std::basic_ostream<char,std::char_traits<char>> &std::operator <<<std::char_traits<char>>(std::basic_ostream<char,std::char_traits<char>> &,const char *)' being compiled (compiling source file C:\Temp\StereoKitBuild\reactphysics3d\src\utils\DefaultLogger.cpp) [C:\Temp\StereoKitBuild\reactphysics3d\build_x64_UWP_Release\reactphysics3d.vcxproj]
And for reference, here's approximately my cmake commands:
cmake -G "Visual Studio 17 2022" -A x64 -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS=/MP -DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=10.0 -DDYNAMIC_LOADER=OFF .. -Wno-dev
cmake --build . --config Release -- /m
Hello. Thanks a lot for your feedback.
Just to let you know that it took me some time to setup a similar environment with Visual Studio and WindowsStore/UWP (I am mostly developing on Linux) but I am working on this issue.
I will let you know when it's done.
In VS 2022 the localtime() is an error not a warning thus preventing a build in release. I found these two stackoverflow solutions with fairly decent explainations. Note that both Unix and Windows are referenced.
https://stackoverflow.com/questions/17982366/localtime-and-asctime-are-unsafe-but-the-safe-functions-dont-have-the-same-par https://stackoverflow.com/questions/38034033/c-localtime-this-function-or-variable-may-be-unsafe
Yes, I have already made a fix in this branch. I need to do more testing but if you want you can already try this branch.
Cool, I will. Thanks.
I have merged the fix into the master branch.
All the errors should be gone except the following one:
warning C4530: C++ exception handler used, but unwind semantics are not enabled
To fix this, you should probably apply the /EHsc parameter as described here.
Let me know if it fixes your issue.