Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

__POSIX_VISIBLE is ruining my pthreading on cygwin

I'm compiling a project that uses pthreads with gcc (g++ exactly) on cygwin. Seeing as how I have always developed this on linux, I never had any problems.

But right now, I am unable to compile code that uses some pthread functions with the compiler complaining that these functions are not declared. I realized that the pthread.h that came with my toolchain, g++ (GCC) 5.4.0, has guarded sections with

#if __POSIX_VISIBLE >= 200112

and these are preventing functions from being available on cygwin/windows.

I attempted searching "__POSIX_VISIBLE" but did not find anything really helpful. What does this actually do and why? I assume it's just that some parts of pthread can't work on windows, or within cygwin or whatever. But why would only some of pthread be blocked under this anyway? It doesn't even complain about -pthread being used.

I plan on changing all the pthread stuff to c++ threads eventually, but right now I'd just like this to compile so I can work on more immediate problems. Is there any way around this if I'm doing it on cygwin/windows?

like image 868
turanc Avatar asked Jul 01 '16 07:07

turanc


1 Answers

looks on /usr/include/sys/features.h for details.

Default is _GNU_SOURCE that includes everthing. Check if your project is restricting the definition with -std or ansi

like image 144
matzeri Avatar answered Oct 26 '22 23:10

matzeri