-
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
Fix msvc annoyances #5963
Fix msvc annoyances #5963
Conversation
src/threading/thread.cpp
Outdated
@@ -311,7 +311,7 @@ bool Thread::bindToProcessor(unsigned int proc_number) | |||
|
|||
bool Thread::setPriority(int prio) | |||
{ | |||
#if USE_WIN_THREADS | |||
#ifdef _WIN32 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is absolutely not how this should be done
change the header file at the point where decision making is done
it always uses c++11 now but seems like @nerzhul forgot to change these
check whether the same change is needed for bindToProcessor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah i forgot and it seems mingw travis build doesn't care... :o
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
soo... how should I handle it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see whether the #if USE_WIN_THREADS
conditions need to be renamed or the code bock removed in this and the other function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be done now.
the remaining failure seems to be a failure of travis itself
@@ -708,9 +708,12 @@ include(CheckCXXCompilerFlag) | |||
|
|||
if(MSVC) | |||
# Visual Studio | |||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++11") | |||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D WIN32_LEAN_AND_MEAN /MP") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps unsurprisingly this causes a lot of warnings on mingw
edcdeb0
to
2c4851b
Compare
@@ -311,7 +311,7 @@ bool Thread::bindToProcessor(unsigned int proc_number) | |||
|
|||
bool Thread::setPriority(int prio) | |||
{ | |||
#if USE_WIN_THREADS | |||
#ifdef _MSC_VER |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use _WIN32 instead for both cases
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
its not compatible with mingw
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I remember correctly because it couldn't cast the return value of getThreadHandle()
to a HANDLE *
(VOID *
). MSVC seems to have either a overload or an implicit cast.
EDIT:
The return value of getThreadHandle()
is std::thread::native_handle_type
which is on Windows (MSVC) just a typedef for a HANDLE
( https://docs.microsoft.com/de-de/cpp/standard-library/thread-class#a-namenativehandlea--threadnativehandle ). On MinGW this seems to be a pthread_t
type (https://stackoverflow.com/questions/19250008/mingw-stdthread-with-windows-api )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a special case for mingw.
Btw: That functions are currently not used, wouldn't it be better to completely remove them? If they are needed some day, they does still exist in git vcs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine to me now.
8ec2ed6
to
703820d
Compare
In some obscure cases 'Windows.h" got includet before that definition, which leaded to compilation warnings+errors
703820d
to
1284717
Compare
Rebased and added another fix that prevented msvc from building: 1284717 |
Thanks |
* MSVC: Fix '/std:c++11' is not a valid compiler option * MSVC/MINGW: Define 'WIN32_LEAN_AND_MEAN' for the whole project In some obscure cases 'Windows.h" got includet before that definition, which leaded to compilation warnings+errors * MSVC: '/arch:SSE' is only available for x86 * MSVC: Fix float conversation * MSVC/MINGW: use winthreads on Windows * MSVC: 'USE_CMAKE_CONFIG' might be already definied by CMake build system * MSVC: Use all available cpu cores for compiling * Add missing include ctime and use std::time_t
* MSVC: Fix '/std:c++11' is not a valid compiler option * MSVC/MINGW: Define 'WIN32_LEAN_AND_MEAN' for the whole project In some obscure cases 'Windows.h" got includet before that definition, which leaded to compilation warnings+errors * MSVC: '/arch:SSE' is only available for x86 * MSVC: Fix float conversation * MSVC/MINGW: use winthreads on Windows * MSVC: 'USE_CMAKE_CONFIG' might be already definied by CMake build system * MSVC: Use all available cpu cores for compiling * Add missing include ctime and use std::time_t
Some annoyances where introduced lately, and some did exist longer.
I hope its clear what every commit is doing.