# include<stdio.h>
# include<graphics.h>
# include<math.h>
using namespace std;
int main(void)
{
int gd=DETECT,gm;
int r,x,y,p,xc=320,yc=240;
initgraph(&gd,&gm,NULL);
cleardevice();
printf("Enter the radius ");
scanf("%d",&r);
x=0;
y=r;
putpixel(xc+x,yc-y,1);
p=3-(2*r);
for(x=0;x<=y;x++)
{
if (p<0)
{
y=y;
p=(p+(4*x)+6);
}
else
{
y=y-1;
p=p+((4*(x-y)+10));
}
putpixel(xc+x,yc-y,1);
putpixel(xc-x,yc-y,2);
putpixel(xc+x,yc+y,3);
putpixel(xc-x,yc+y,4);
putpixel(xc+y,yc-x,5);
putpixel(xc-y,yc-x,6);
putpixel(xc+y,yc+x,7);
putpixel(xc-y,yc+x,8);
}
getch();
closegraph();
}
- 已安装graphics.h
- 使用编译
gcc filename.cpp -0 filename -lgraph
- 然后使用
./filename
- 该窗口出现了10秒,然后出现以下错误:
[xcb] 处理队列时出现未知序列号 [xcb] 这很可能是一个多线程客户端,并且尚未调用 XInitThreads [xcb] 中止,对此深感抱歉。 心脏:../../src/xcb_io.c:273:poll_for_event:断言“!xcb_xlib_threads_sequence_lost”失败。 已中止
有什么解决办法吗?
答案1
有一个错误已提交至 Launchpad与上述问题非常相似。
一信息包含来自源的引文,详细说明了何时发生此错误情况:
错误消息“处理队列时出现未知序列号”出现在一大段文本中,该文本前面有一条很大的警告,涉及客户端代码中的线程安全:
/* Thread-safety rules: * * At most one thread can be reading from XCB's event queue at a time. * If you are not the current event-reading thread and you need to find * out if an event is available, you must wait. * * The same rule applies for reading replies. * * A single thread cannot be both the the event-reading and the * reply-reading thread at the same time. * * We always look at both the current event and the first pending reply * to decide which to process next. * * We always process all responses in sequence-number order, which may * mean waiting for another thread (either the event_waiter or the * reply_waiter) to handle an earlier response before we can process or * return a later one. If so, we wait on the corresponding condition * variable for that thread to process the response and wake us up. */
这似乎表明该客户端应用程序在与 xcb 调用相关的线程处理中可能存在一些错误逻辑?