繁体   English   中英

Netbeans 7.3突出了C ++的错误错误

[英]Netbeans 7.3 highlights false errors C++

我在昨天安装了Netbeans 7.3想要的更新,我正在运行Ubuntu 12.04。 现在,当我创建一个新项目时,netbeans突出显示了我的代码中的许多错误,但是当我构建时,它编译并运行时没有错误。

这是一个简单的例子,我在评论中添加了netbeans声称代码所包含的错误。

main.cpp中

#include <cstdlib>
#include <string>
#include <stdio.h>
#include "hello.h"
using namespace std;

int main()
{
    string s="hello";
    printf("%i\n",s.length()); //Unable to resolve identifier length
    hello h(0,0,0); //unable to resolve identifier hello
    printf("%i\n",h.z); //unable to resolve identifier z
    return 0;
}

hello.h

#ifndef HELLO_H
#define HELLO_H
class hello
{
public: //unexpected token: :
    int x;
    int y;
    int z;
    hello(int px,int py,int pz);
}; //unexpected token: }
#endif  

HELLO.CPP

#include "hello.h"
hello::hello(int px, int py, int pz) //method hello does not have declaration
{
    x=px;
    y=py;
    z=pz;
}

我尝试编译,清理和重建,重新启动netbeans,并在新项目中进行此操作,但没有任何作用。 有任何想法吗?

在此先感谢您的帮助 :)

我曾经遇到过同样的问题。 我需要删除{userdir}/var/cache/index下的用户缓存

我发现了错误报告来自这里:

https://netbeans.org/bugzilla/show_bug.cgi?id=153158

我重新安装netbeans,它修复了大部分问题,当我花了一段时间从项目中删除文件然后再添加它们时,其余的都消失了。 检查文件的属性并确保它们设置为使用c ++编译而不是c也有帮助。 希望这个问题不会再回来困扰我了。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM