[英]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
下的用戶緩存
我發現了錯誤報告來自這里:
我重新安裝netbeans,它修復了大部分問題,當我花了一段時間從項目中刪除文件然后再添加它們時,其余的都消失了。 檢查文件的屬性並確保它們設置為使用c ++編譯而不是c也有幫助。 希望這個問題不會再回來困擾我了。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.