-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fixed 'localtime_*' compilation error MinGW #393
Conversation
I naively took my change from #392 |
concerning my previous comment: my error about std::mutex is due to MinGW (again :s) that still haven't a standard threads implementation. Users of MinGW can either:
(we could detect MinGW and automatically add this macro in the code or just wait the MinGW's team) Anyway, I don't know why travis failed here. |
travis failed due to a finicky timer test that I should probably remove since it gets a lot of false positives. Falling back to boost thread would be a good default here. I'll look into autodetecting that. A few things you could help me with in that regard:
|
I am not an expert in MinGW, so I compiled this code for answering your question: #include <iostream>
int main( void ) {
auto func = [] { std::cout << "__cplusplus : " << __cplusplus << std::endl; };
func();
return 0;
} and I got the following input:
Consequently, I would answer
|
I've pushed an update to the C++11 thread support detection code that should force the use of boost thread by default for MinGW even when it is building in C++11 mode. Can you confirm that this fixes the issue you were seeing without requiring you to include any special preprocessor defines? |
Confirmed; I checkout from 'develop' branch (replaced websocketpp\common\time.hpp with the changes on this pull request) and no error. Note that in "if (defined(MINGW32) || defined(MINGW64))", checking MINGW64 is not really necessary because I think mingw64 defines also MINGW32. Thus, checking MINGW32 alone could be enough. But for me, it's more clear for an external readers that might think MINGW64 is missing. |
fixed 'localtime_*' compilation error MinGW
I got the following compilation error when compiling a project including websocketpp with MinGW:
[ 95%] Building CXX object CMakeFiles/Sources/MyProject/CMakeFiles/MyProject.dir/TestClient.cpp.obj
In file included from F:/Project/MyProject/build/cmake/../../extlibs/include/websocketpp/logger/basic.hpp:49:0,
from F:/Project/MyProject/build/cmake/../../extlibs/include/websocketpp/config/core.hpp:51,
from F:/Project/MyProject/build/cmake/../../extlibs/include/websocketpp/config/asio_no_tls.hpp:31,
from F:\Project\MyProject\Sources\MyProject\WebSocketClient.hpp:8,
from F:\Project\MyProject\Sources\MyProject\TestClient.hpp:34,
from F:\Project\MyProject\Sources\MyProject\TestClient.cpp:2:
F:/Project/MyProject/build/cmake/../../extlibs/include/websocketpp/common/time.hpp: In function 'tm websocketpp::lib::localtime(const time_t&)':
F:/Project/MyProject/build/cmake/../../extlibs/include/websocketpp/common/time.hpp:44:36: error: 'localtime_s' was not declared in this scope
localtime_s(&tm_snapshot, &time);
^
compilation terminated due to -Wfatal-errors.
CMakeFiles\Sources\MyProject\CMakeFiles\MyProject.dir\build.make:57: recipe for target 'CMakeFiles/Sources/MyProject/CMakeFiles/MyProject.dir/TestClient.cpp.obj' failed
make[3]: *** [CMakeFiles/Sources/MyProject/CMakeFiles/MyProject.dir/TestClient.cpp.obj] Error 1
CMakeFiles\Makefile2:1063: recipe for target 'CMakeFiles/Sources/MyProject/CMakeFiles/MyProject.dir/all' failed
make[2]: *** [CMakeFiles/Sources/MyProject/CMakeFiles/MyProject.dir/all] Error 2
CMakeFiles\Makefile2:1075: recipe for target 'CMakeFiles/Sources/MyProject/CMakeFiles/MyProject.dir/rule' failed
make[1]: *** [CMakeFiles/Sources/MyProject/CMakeFiles/MyProject.dir/rule] Error 2
Makefile:329: recipe for target 'MyProject' failed
make: *** [MyProject] Error 2
Note
MinGW does not define neither localtime_s nor locatime_r.
Discussion here: http://stackoverflow.com/questions/18551409/localtime-r-support-on-mingw
MinGW Note here: http://sourceforge.net/p/mingw-w64/mailman/message/21523522/