__POSIX_VISIBLE破坏了我在cygwin上的线程 [英] __POSIX_VISIBLE is ruining my pthreading on cygwin

查看:276
本文介绍了__POSIX_VISIBLE破坏了我在cygwin上的线程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编译一个在cygwin上使用带有gcc的pthreads(完全是g ++)的项目.就像我一直在linux上开发它一样,我从来没有遇到任何问题.

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.

但是现在,我无法编译使用某些pthread函数的代码,而编译器会抱怨这些函数未声明.我意识到,我的工具链g ++(GCC)5.4.0附带的pthread.h已经用

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

并且这些阻止了在cygwin/windows上可用的功能.

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

我尝试搜索"__POSIX_VISIBLE",但没有发现任何真正有用的信息.这实际上是做什么的,为什么呢?我以为只是pthread的某些部分不能在Windows或Cygwin或任何其他工具上运行.但是为什么在这种情况下为什么只会阻止 some 的pthread?它甚至没有抱怨使用-pthread.

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.

我计划最终将所有pthread内容更改为c ++线程,但是现在我希望将其编译为可以解决更紧急问题的方法.如果我在cygwin/windows上可以解决此问题?

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?

推荐答案

/usr/include/sys/features.h上显示 有关详细信息.

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

默认值为_GNU_SOURCE,其中包含所有内容. 检查您的项目是否使用-stdansi

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

这篇关于__POSIX_VISIBLE破坏了我在cygwin上的线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆