编译期间出错 [英] Error Occured during compilation

查看:201
本文介绍了编译期间出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我正在为CYGWIN中的nanosleep编译代码。

在编译期间我收到以下错误


Socket.cc:在方法`bool Socket :: hangOnConnection(int = 0)'':

Socket.cc:338:聚合`struct timespec tmsp''具有不完整的类型和

不能b
$ b $被初始化

源于它的源是


bool Socket :: hangOnConnection(int nNanoSecond)

{

struct timespec tmsp;

/*tmsp.tv_sec =(time_t)0;

if(nNanoSecond)tmsp.tv_nsec = nNanoSecond;

else tmsp.tv_nsec = 110;

if(nanosleep(& tmsp,NULL)< 0)

{

DEBUG_MSG(在hangOn期间出现错误);

返回false;

} * /

返回true;

}


" struct timespec"在< sys / types.h>中定义了


请建议我如何调试


最好的问候,

Abdur

Hi,

I am compiling code for nanosleep in CYGWIN.
During compilation i get the following error

Socket.cc: In method `bool Socket::hangOnConnection(int = 0)'':
Socket.cc:338: aggregate `struct timespec tmsp'' has incomplete type and
cannot b
e initialized
The Source realted to it is

bool Socket :: hangOnConnection (int nNanoSecond)
{
struct timespec tmsp;
/*tmsp.tv_sec = (time_t) 0;
if (nNanoSecond) tmsp.tv_nsec = nNanoSecond;
else tmsp.tv_nsec = 110;
if (nanosleep (&tmsp, NULL) < 0)
{
DEBUG_MSG ("Error occured during hangOn");
return false;
}*/
return true;
}

"struct timespec" is defined in <sys/types.h>

Please suggest me how to debug it

Best Regards,
Abdur

推荐答案

ab ******** @ yahoo.co.in 中写道:
ab********@yahoo.co.in wrote:

bool Socket :: hangOnConnection(int nNanoSecond)
{struct timespec tmsp;
/*tmsp.tv_sec =(time_t)0;
if(nNanoSecond)tmsp.tv_nsec = nNanoSecond;

bool Socket :: hangOnConnection (int nNanoSecond)
{
struct timespec tmsp;
/*tmsp.tv_sec = (time_t) 0;
if (nNanoSecond) tmsp.tv_nsec = nNanoSecond;




请在更合适的新闻组中提出这个问题。

comp.os.linux.development。*可能是一个好地方。


-

Madhav。



Please ask this question in a more appropriate newsgroup.
comp.os.linux.development.* might be a good place.

--
Madhav.


ab ******** @ yahoo.co.in 写道:

.... snip ...
bool Socket :: hangOnConnection(int nNanoSecond)
^^^^ ^^

语法错误。

要使用bool,你必须#include< stdbool.h>,然后使用C99。

{
struct timespec tmsp;


未定义的结构。

/*tmsp.tv_sec =(time_t)0;
if(nNanoSecond)tmsp.tv_nsec = nNanoSecond;
else tmsp.tv_nsec = 110;
if(nanosleep(& tmsp,NULL)< 0)


nanosleep undefined。缺少'')''。

{
DEBUG_MSG(" hangOn期间出现错误);
DEBUG_MSG undefined return false;


false undefined

} * /
返回true;


true undefined

}

" struct timespec"在< sys / types.h>中定义了
.... snip ...
The Source realted to it is

bool Socket :: hangOnConnection (int nNanoSecond) ^^^^ ^^
Syntax errors.
To use bool you must #include <stdbool.h>, and be using C99.
{
struct timespec tmsp;
Undefined struct.
/*tmsp.tv_sec = (time_t) 0;
if (nNanoSecond) tmsp.tv_nsec = nNanoSecond;
else tmsp.tv_nsec = 110;
if (nanosleep (&tmsp, NULL) < 0)
nanosleep undefined. Missing '')''.
{
DEBUG_MSG ("Error occured during hangOn"); DEBUG_MSG undefined return false;
false undefined
}*/
return true;
true undefined
}

"struct timespec" is defined in <sys/types.h>




不,不是。 ISO标准中没有定义这样的头文件

C.你在这里既不是C也不是主题。让你到处理你的语言和/或系统的
新闻集团。当你通过剪切和粘贴找到这样的邮件可编辑代码,而不是重新输入。

-

"如果你想发布一个后续内容通过groups.google.com,不要使用

破损的回复链接在文章的底部。点击

" show options"在文章的顶部,然后点击

回复在文章标题的底部。 - Keith Thompson

详情请见:< http://cfaj.freeshell.org/google/>



No it isn''t. There is no such header file defined in ISO standard
C. What you have here is neither C nor topical. Get thee to a
newsgroupery dealing with your language and/or system. When you
find such post compilable code via cut and paste, not retyping.
--
"If you want to post a followup via groups.google.com, don''t use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell.org/google/>


" ab * *******@yahoo.co.in" < AB ******** @ yahoo.co.in>写道:
"ab********@yahoo.co.in" <ab********@yahoo.co.in> writes:
我正在编译CYGWIN中的nanosleep代码。
在编译期间我得到以下错误

Socket.cc:在方法`bool Socket :: hangOnConnection (int = 0)'':
Socket.cc:338:聚合`struct timespec tmsp''类型不完整且
无法初始化

源于它的源是

bool Socket :: hangOnConnection(int nNanoSecond)
{struct timespec tmsp;
/*tmsp.tv_sec =(time_t)0;
if(nNanoSecond)tmsp.tv_nsec = nNanoSecond;
else tmsp.tv_nsec = 110;
if(nanosleep(& tmsp,NULL)< 0)
{
DEBUG_MSG(在hangOn期间发生错误);
返回false;
} * /
返回true;
}

" struct的timespec"在< sys / types.h>中定义

请建议我如何调试它
I am compiling code for nanosleep in CYGWIN.
During compilation i get the following error

Socket.cc: In method `bool Socket::hangOnConnection(int = 0)'':
Socket.cc:338: aggregate `struct timespec tmsp'' has incomplete type and
cannot b
e initialized
The Source realted to it is

bool Socket :: hangOnConnection (int nNanoSecond)
{
struct timespec tmsp;
/*tmsp.tv_sec = (time_t) 0;
if (nNanoSecond) tmsp.tv_nsec = nNanoSecond;
else tmsp.tv_nsec = 110;
if (nanosleep (&tmsp, NULL) < 0)
{
DEBUG_MSG ("Error occured during hangOn");
return false;
}*/
return true;
}

"struct timespec" is defined in <sys/types.h>

Please suggest me how to debug it




您的代码是C ++,而不是C. comp.lang.c ++位于左侧大厅。


部分代码可能有效C.我对有
$ b持怀疑态度$ b不完整类型且无法初始化消息,因为你没有
实际初始化tmpsp。你说struct timespec是在

< sys / types.h>中定义的,但你发布的代码没有#include

那个标题。


编写一个小型,自包含的程序来说明问题。

用C或C ++编写,然后发布到相应的新闻组。 />
发布您输入编译器的确切代码;不要试图重新输入

或者总结它。


-

Keith Thompson(The_Other_Keith)< a href =mailto:ks *** @ mib.org> ks *** @ mib.org < http://www.ghoti.net/~kst>

圣地亚哥超级计算机中心< *> < http://users.sdsc.edu/~kst>

我们必须做点什么。这是事情。因此,我们必须这样做。



Your code is C++, not C. comp.lang.c++ is down the hall on the left.

Parts of your code could be valid C. I''m suspicious about the "has
incomplete type and cannot be initialized" message, since you don''t
actually initialize tmpsp. You say that struct timespec is defined in
<sys/types.h>, but the code you posted doesn''t have a #include for
that header.

Write a small, self-contained program that illustrates the problem.
Write it in either C or C++, and post to the appropriate newsgroup.
Post the exact code that you fed to the compiler; don''t try to re-type
it or summarize it.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.


这篇关于编译期间出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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