本文介绍了编译期间出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我正在为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>中定义了 请建议我如何调试 最好的问候, AbdurHi,I am compiling code for nanosleep in CYGWIN.During compilation i get the following errorSocket.cc: In method `bool Socket::hangOnConnection(int = 0)'':Socket.cc:338: aggregate `struct timespec tmsp'' has incomplete type andcannot be initializedThe Source realted to it isbool 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 itBest Regards,Abdur推荐答案 请在更合适的新闻组中提出这个问题。 comp.os.linux.development。*可能是一个好地方。 - Madhav。Please ask this question in a more appropriate newsgroup.comp.os.linux.development.* might be a good place.--Madhav. 不,不是。 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 standardC. What you have here is neither C nor topical. Get thee to anewsgroupery dealing with your language and/or system. When youfind such post compilable code via cut and paste, not retyping.--"If you want to post a followup via groups.google.com, don''t usethe 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 ThompsonMore details at: <http://cfaj.freeshell.org/google/> 您的代码是C ++,而不是C. comp.lang.c ++位于左侧大厅。 部分代码可能有效C.我对有 $ b持怀疑态度$ b不完整类型且无法初始化消息,因为你没有实际初始化tmpsp。你说struct timespec是在 < sys / types.h>中定义的,但你发布的代码没有#include 那个标题。 编写一个小型,自包含的程序来说明问题。 用C或C ++编写,然后发布到相应的新闻组。 /> 发布您输入编译器的确切代码;不要试图重新输入 或者总结它。 - Keith Thompson(The_Other_Keith) 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 "hasincomplete type and cannot be initialized" message, since you don''tactually initialize tmpsp. You say that struct timespec is defined in<sys/types.h>, but the code you posted doesn''t have a #include forthat 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-typeit 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. 这篇关于编译期间出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-06 20:27