Hi all or dear people,
Regarding the greeting please choose the one that best matches your
formality preference to which you view the mailing list members :)
Alright, I would like to talk about the thread support of
x86_64-8.1.0-release-win32-sjlj-rt_v6-rev0 as well as
x86_64-8.1.0-release-win32-seh-rt_v6-rev0
On my Windows 7 computer, without any msys things, which I don't want to
use.
So, the folder: path/to/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++
contains the header file "thread". It seems I have to define
_GLIBCXX_HAS_GTHREADS and _GLIBCXX_USE_C99_STDINT_TR1 to get the
implementation enabled. But I don't know if thats the right way to do it.
The thread header in turn include the file gthr.h located in:
path/to/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/x86_64-w64-mingw32/bits
but the implementation is commented out.
I was trying some very basic thread example code (attached.) to get it to
compile. But that doesn't seem to work (see result.txt)
My questions are:
1) What does threading in the mingw64 win32 build variants actually offer?
2) How should I modify my example code to get it to work with native Windows
threads? You know in a way that the resulting executable actually calls the
Windows API CreateThread function among others..
3) If this is not possible why do the headers like thread and mutex exist in
the mingw win32 thread builds?
Best regards,
Maarten Verhage
#define _GLIBCXX_HAS_GTHREADS 1
#define _GLIBCXX_USE_C99_STDINT_TR1 1
#include <stdio.h>
#include <thread>
void thread_function()
{
printf( "1" );
}
int main()
{
printf( "__cplusplus: %d\n", __cplusplus );
std::thread thread1( thread_function );
printf( "2" );
thread1.join();
return EXIT_SUCCESS;
}FLAGS = -std=c++17 -pedantic -Wextra -Wlogical-op
LIBSWIN = -l:libkernel32.a -l:libuser32.a -l:libshell32.a -l:libadvapi32.a\
-l:libws2_32.a -l:liboleaut32.a -l:libimm32.a -l:libwinmm.a
-l:libole32.a\
-l:libuuid.a -l:libopengl32.a -l:libole32.a -l:libgdi32.a
all: test.exe
test.exe : test.o
g++ -static -mconsole -Xlinker -Map=test_map.txt test.o $(LIBSWIN) -o
test.exe
test.o : test.cpp
g++ -c -O0 $(FLAGS) -g test.cpp > result.txt 2>&1
clean:
del test.o test.exeIn file included from test.cpp:5:
C:/dev/x86_64-8.1.0-release-win32-sjlj-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/thread:74:13:
error: '__gthread_t' does not name a type; did you mean '__threadid'?
typedef __gthread_t native_handle_type;
^~~~~~~~~~~
__threadid
C:/dev/x86_64-8.1.0-release-win32-sjlj-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/thread:79:7:
error: 'native_handle_type' does not name a type
native_handle_type _M_thread;
^~~~~~~~~~~~~~~~~~
C:/dev/x86_64-8.1.0-release-win32-sjlj-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/thread:85:28:
error: expected ')' before '__id'
id(native_handle_type __id) : _M_thread(__id) { }
~ ^~~~~
)
C:/dev/x86_64-8.1.0-release-win32-sjlj-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/thread:168:5:
error: 'native_handle_type' does not name a type
native_handle_type
^~~~~~~~~~~~~~~~~~
C:/dev/x86_64-8.1.0-release-win32-sjlj-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/thread:
In constructor 'std::thread::id::id()':
C:/dev/x86_64-8.1.0-release-win32-sjlj-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/thread:82:23:
error: class 'std::thread::id' does not have any field named '_M_thread'
id() noexcept : _M_thread() { }
^~~~~~~~~
C:/dev/x86_64-8.1.0-release-win32-sjlj-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/thread:
In function 'bool std::operator==(std::thread::id, std::thread::id)':
C:/dev/x86_64-8.1.0-release-win32-sjlj-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/thread:273:16:
error: 'class std::thread::id' has no member named '_M_thread'
return __x._M_thread == __y._M_thread;
^~~~~~~~~
C:/dev/x86_64-8.1.0-release-win32-sjlj-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/thread:273:33:
error: 'class std::thread::id' has no member named '_M_thread'
return __x._M_thread == __y._M_thread;
^~~~~~~~~
C:/dev/x86_64-8.1.0-release-win32-sjlj-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/thread:
In function 'bool std::operator<(std::thread::id, std::thread::id)':
C:/dev/x86_64-8.1.0-release-win32-sjlj-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/thread:285:16:
error: 'class std::thread::id' has no member named '_M_thread'
return __x._M_thread < __y._M_thread;
^~~~~~~~~
C:/dev/x86_64-8.1.0-release-win32-sjlj-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/thread:285:32:
error: 'class std::thread::id' has no member named '_M_thread'
return __x._M_thread < __y._M_thread;
^~~~~~~~~
C:/dev/x86_64-8.1.0-release-win32-sjlj-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/thread:
In member function 'std::size_t std::hash<std::thread::id>::operator()(const
std::thread::id&) const':
C:/dev/x86_64-8.1.0-release-win32-sjlj-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/thread:308:43:
error: 'const class std::thread::id' has no member named '_M_thread'
{ return std::_Hash_impl::hash(__id._M_thread); }
^~~~~~~~~
C:/dev/x86_64-8.1.0-release-win32-sjlj-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/thread:
In function 'std::basic_ostream<_CharT, _Traits>&
std::operator<<(std::basic_ostream<_CharT, _Traits>&, std::thread::id)':
C:/dev/x86_64-8.1.0-release-win32-sjlj-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/thread:318:23:
error: 'class std::thread::id' has no member named '_M_thread'
return __out << __id._M_thread;
^~~~~~~~~
C:/dev/x86_64-8.1.0-release-win32-sjlj-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/thread:
In function 'std::thread::id std::this_thread::get_id()':
C:/dev/x86_64-8.1.0-release-win32-sjlj-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/thread:339:25:
error: '__gthread_self' was not declared in this scope
return thread::id(__gthread_self());
^~~~~~~~~~~~~~
C:/dev/x86_64-8.1.0-release-win32-sjlj-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/thread:339:25:
note: suggested alternative: '__gthread_once'
return thread::id(__gthread_self());
^~~~~~~~~~~~~~
__gthread_once
C:/dev/x86_64-8.1.0-release-win32-sjlj-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/thread:
In function 'void std::this_thread::yield()':
C:/dev/x86_64-8.1.0-release-win32-sjlj-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/thread:347:7:
error: '__gthread_yield' was not declared in this scope
__gthread_yield();
^~~~~~~~~~~~~~~
C:/dev/x86_64-8.1.0-release-win32-sjlj-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/thread:347:7:
note: suggested alternative: '__gthread_once'
__gthread_yield();
^~~~~~~~~~~~~~~
__gthread_once
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public