Reputation: 443
I installed the updates Netbeans 7.3 wanted me to yesterday, and I'm running Ubuntu 12.04. Now, when I create a new project, netbeans highlights a lot of errors in my code, but when I build, it compiles and runs with no errors.
Here's a simple example where I added the errors netbeans claims the code has in the comments.
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;
}
I tried compiling, cleaning and rebuilding, restarting netbeans, and making this in a new project, and nothing works. Any ideas?
Thanks in advance for your help :)
Upvotes: 1
Views: 1701
Reputation: 443
I reinstalled netbeans, which fixed most of the problems, and the rest went away when I spent a while removing the files from the project and then adding them back. Checking the file's properties and ensuring they were set to be compiled with c++ and not c also helped. Hopefully this problem won't come back to haunt me again.
Upvotes: 1
Reputation: 4335
I had this same problem once. I needed to delete the user cache under {userdir}/var/cache/index
I found the bug report where this came from here:
https://netbeans.org/bugzilla/show_bug.cgi?id=153158
Upvotes: 3