Pithikos / C-Thread-Pool

A minimal but powerful thread pool in ANSI C
MIT License
2.06k stars 603 forks source link

Errors when compiling with C++ #95

Open ntmchau2202 opened 3 years ago

ntmchau2202 commented 3 years ago

I've found your threadpool incredible and am using it for my C++ project. However, when I built it with g++ and c++11 library (option -std=c++11 ), i got into this issue:

thpool.c:68:3: error: changes meaning of ‘jobqueue’ from ‘typedef struct jobqueue jobqueue’ [-fpermissive] } jobqueue;

I've searched for solution and found out that princessannabelle had issued this on 2017. However, the problems may not lie in the worker function, but in some structure names that you've defined in thpool.cpp. Some of them are the same as some of your varriables, so that g++ got confused and raised errors, which may not happen with gcc due to differences in privacy of the 2 compilers.

I tried to change all the duplicated names and things works fine.

So, i opened this issue and suggest some modifications so that both C and C++ users can enjoy your work with more convenient. Here are my changes on your code that flow fine.

Thanks for your consideration

Screenshot_648 Screenshot_649 Screenshot_650 Screenshot_651 Screenshot_652