gerhobbelt / pthread-win32 Goto Github PK
View Code? Open in Web Editor NEWclone of pthread-win32 (a.k.a. pthreads4w) + local tweaks (including MSVC2008 - MSVC2022 project files)
License: Other
clone of pthread-win32 (a.k.a. pthreads4w) + local tweaks (including MSVC2008 - MSVC2022 project files)
License: Other
When building the solution using MSVC2019 (tested on Visual Studio 2019, v16.9.5 and latest 16.9.6), every source file outputs this line in the Output window in Visual Studio.
Upon investigation, this turns out to be a Microsoft Windows 10 SDK bug:
This is a bug in the Windows SDK which surfaces as a preprocessor warning when compiling in C17 mode, rather than "Legacy Mode", which we switched away from in commit 1357369
Observe the bug in C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um\WinBase.h
in this section: note the !defined(_WINBASE_)
in there in the result, which is where this preproceessor function WILL NOT WORK:
/*
To turn off/hide the contents of this file:
#define MICROSOFT_WINDOWS_WINBASE_H_DEFINE_INTERLOCKED_CPLUSPLUS_OVERLOADS 0
*/
#if !defined(MICROSOFT_WINDOWS_WINBASE_H_DEFINE_INTERLOCKED_CPLUSPLUS_OVERLOADS)
#define MICROSOFT_WINDOWS_WINBASE_H_DEFINE_INTERLOCKED_CPLUSPLUS_OVERLOADS (_WIN32_WINNT >= 0x0502 || !defined(_WINBASE_))
#endif
#if MICROSOFT_WINDOWS_WINBASE_H_DEFINE_INTERLOCKED_CPLUSPLUS_OVERLOADS /* { */
and now here's the patched version, which does the proper thing - a lo, the issue goes away:
/*
To turn off/hide the contents of this file:
#define MICROSOFT_WINDOWS_WINBASE_H_DEFINE_INTERLOCKED_CPLUSPLUS_OVERLOADS 0
*/
#if !defined(MICROSOFT_WINDOWS_WINBASE_H_DEFINE_INTERLOCKED_CPLUSPLUS_OVERLOADS)
#if (_WIN32_WINNT >= 0x0502 || !defined(_WINBASE_))
#define MICROSOFT_WINDOWS_WINBASE_H_DEFINE_INTERLOCKED_CPLUSPLUS_OVERLOADS 1
#else
#define MICROSOFT_WINDOWS_WINBASE_H_DEFINE_INTERLOCKED_CPLUSPLUS_OVERLOADS 0
#endif
#endif
#if MICROSOFT_WINDOWS_WINBASE_H_DEFINE_INTERLOCKED_CPLUSPLUS_OVERLOADS /* { */
Apparently nobody at MS tested the SDK in C17 mode or this should have popped up as soon as you compile anything that includes WinBase.h one way or another. 🤷♀️
Filing it here so it can be found. Had a look at the doldrum that's MS bug reporting for devs and I don't like the wall at all:
I get it that you do that kind of thing to keep the loonies away and unload your team, but here's another team that doesn't need the hassle, so filing, patching locally and moving on. Google Search will decide, in the end.
Hi Ger,
I plan on creating a cmake solution for pthread-win32.
It would be a better way to handle different Visual studio version changes.
Your though's on this and on maybe helping me?
Cheers
Martell
Hi,
I noticed that when I runned the tests suite the tsd3 test is missing,
it is normal that there is no such tsd3.c or did I just miss something and its generated else where ?
I use GC-static-debug for both lib and tests
thanks for your help
Pierre
I'm not sure if this is a bug in the VS2015 project file or if there's been a typo for 6 years in sched.h, but the following fixes the build error for me and I was able to get it to build.
Change line 47 from:
#include <_ptw32.h>
to
#include "_ptw32.h"
As the title, the problem is solved by adding the file to the source dir.
But the result seems to be odd. The size of pthread_dll.dll is 59KB and the size of its corresponding lib is 33KB.
And the pthread_lib.lib is quite big, about 14MB . Any solution?
Attempting to compile by using the Microsoft Visual Studio 2008. The project does not compile.
133 errors.
Most are the error:
fatal error C1189: #error : "config.h was not #included"
The remaining errors are related to missing files, such as:
fatal error C1083: Cannot open source file: '.\fork.c': No such file or directory
fatal error C1083: Cannot open source file: '.\spin.c': No such file or directory
Hi @GerHobbelt,
Would you be able to help me with something.
I want to change pthreads.h pthread_t from a struct to a uintptr_t
As gcc assumes a scalar value for c++11 threading
I don't know how to propagate this change throughout pthread without breaking it :(
and I really need todo this
this is the error gcc will produce
libstdc++-v3/include/thread:88:30: error: no match for ‘operator<’ (operand types are ‘std::thread::native_handle_type {aka pte_handle_t}’ and ‘std::thread::native_handle_type {aka pte_handle_t}’) { return __x._M_thread < __y._M_thread; }
Hello
My Visual Studio 2017 can't find the autostatic.c file.
Can you please enlighten me what is wrong ?
Best regards, Jan
Hey.
I'm cloning a branch master. Immediately check the status and get a list of modifications.
Checked on Windows 10 and Arch Linux. On Linux, only 3 files from the tests folder.
What could be the problem?
modified: manual/cpu_set.html
modified: manual/index.html
modified: manual/pthread_create.html
modified: manual/pthread_join.html
modified: manual/sched_setaffinity.html
modified: pthread_setaffinity.c
modified: pthread_timedjoin_np.c
modified: pthread_tryjoin_np.c
modified: sched_setaffinity.c
modified: tests/affinity1.c
modified: tests/affinity2.c
modified: tests/affinity3.c
modified: tests/affinity4.c
modified: tests/affinity5.c
modified: tests/context2.c
modified: tests/exception3_0.c
modified: tests/join4.c
Hello Ger,
I get the following in VS2019:
sched_setscheduler.c(65,60): warning C4244: 'function': conversion from 'pid_t' to 'DWORD', possible loss of data
sched_getscheduler.c(63,62): warning C4244: 'function': conversion from 'pid_t' to 'DWORD', possible loss of data
Maybe a cast here would be OK, but someone should probably check..
Thanks,
/pedro
Hi,
When following the compilation guide written in the readme file, i got the following output:
C:\Users\TEST\Downloads\pthread-win32-master\pthread-win32-master>nmake realclea
n VC
Microsoft (R) Program Maintenance Utility Version 10.00.30319.01
Copyright (C) Microsoft Corporation. All rights reserved.
if exist *.obj del *.obj
if exist *.def del *.def
if exist *.ilk del *.ilk
if exist *.pdb del *.pdb
if exist *.exp del *.exp
if exist *.map del *.map
if exist *.o del *.o
if exist *.i del *.i
if exist *.res del *.res
if exist *.dll del *.dll
if exist *.lib del *.lib
if exist *.a del *.a
if exist *.manifest del *.manifest
if exist *_stamp del *_stamp
cd tests && "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\Bin\
nmake.exe" clean
Microsoft (R) Program Maintenance Utility Version 10.00.30319.01
Copyright (C) Microsoft Corporation. All rights reserved.
if exist *.dll erase *.dll
if exist *.lib erase *.lib
if exist pthread.h erase pthread.h
if exist semaphore.h erase semaphore.h
if exist sched.h erase sched.h
if exist *.e erase *.e
if exist *.i erase *.i
if exist *.obj erase *.obj
if exist *.pdb erase *.pdb
if exist *.o erase *.o
if exist *.asm erase *.asm
if exist *.exe erase *.exe
if exist *.manifest erase *.manifest
if exist *.pass erase *.pass
if exist *.bench erase *.bench
if exist *.log erase *.log
cl /I. /DHAVE_CONFIG_H /O2 /Ob2 /W3 /MD /nologo /DPTW32_BUILD_INLINED /D
__CLEANUP_C -c pthread.c
pthread.c
c:\users\test\downloads\pthread-win32-master\pthread-win32-master\dll.c(45) : fa
tal error C1189: #error : "Should not compile dynamic library code when apparen
tly trying to build a static lib"
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 10.0
\VC\Bin\cl.EXE"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 10.0
\VC\Bin\nmake.exe"' : return code '0x2'
Stop.
My configuration is :
Windows 7 64b
MSVS 2010 express
Windows SDK 7.1
FYI, I had the same issue when trying to compile on several computers, with different versions of MSVS.
Thanks for your help.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.