Giter Club home page Giter Club logo

pthread-win32's Issues

C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um\winbase.h(9531,5): warning C5105: macro expansion producing 'defined' has undefined behavior (compiling source file ......)

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.

Diagnosis and Fix

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.

Cmake Solution

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

missing test tsd3 using i686-w64-mingw32-gcc

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

VS2015, pthread_dll solution lacks ptw32_strdup.c

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?

VS 2008 project does not compile

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

pthread_t need to be a scalar to satisfy gcc

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; }

Modified files by default

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

vs2019: warning in sched_getscheduler.c and sched_setscheduler.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

MSVS compilation issue

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.