Recently, I've had some trouble trying to get std::thread working with MinGW g++. Considering that I don't want a dependency on gthread, I was wondering if I could use thread.cc (and cxxabi_forced.h) with the following macro functions instead:

#define __gthread_t thrd_t
#define __gthread_create(a, b, c) thrd_create(a, (thrd_start_t)b, c)
#define __gthread_join thrd_join
#define __gthread_detach thrd_detach
#define __gthread_self thrd_current
#define __gthread_yield thrd_yield

However, as the GCC Runtime Library Exception states:

use of source code generators and preprocessors need not be considered part of the Compilation Process, since the Compilation Process can be understood as starting with the output of the generators or preprocessors.

This makes me think that in the first example, the whole code is now covered by GPLv3 due to some macros changing the code itself. So, I came up with another idea:

typedef thrd_t __gthread_t;
int __gthread_create(thrd_t *thr, void *func(void*), void *arg) {
    return thrd_create(thr, (thrd_start_t)func, arg);
int __gthread_join(__gthread_t thr, int *res) {
    return thrd_join(thr, res);
int __gthread_detach(__gthread_t thr) {
    return thrd_detach(thr);
__gthread_t __gthread_self(void) {
    return thrd_current();
void __gthread_yield(void) {

In this line of code below, you can see that _GLIBCXX_HAS_GTHREADS was set to 1 just so that thread.cc would function properly.

#if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1)

I assume this doesn't cause licensing problems. Can I use the last example in combination with non-GPLv3 compatible software? Is it true that the first example is completely covered by GPLv3?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.