views:

221

answers:

2

Hi,

My IDE (NetBeans) thinks this is wrong code, but it compiles correct:

std::cout << "i = " << i << std::endl;
std::cout << add(5, 7) << std::endl;
std::string test = "Boe";
std::cout << test << std::endl;

He always says: unable to resolve identifier .... (.... = cout, endl, string);

So I think it has something to do with the code assistance. I think I have to change/add/remove some folders.
Currently, I have this include folders:

C compiler:

/usr/local/include
/usr/lib/gcc/i486-linux-gnu/4.4.3/include
/usr/lib/gcc/i486-linux-gnu/4.4.3/include-fixed
/usr/include

C++ compiler:

/usr/include/c++/4.4.3
/usr/include/c++/4.4.3/i486-linux-gnu
/usr/include/c++/4.4.3/backward
/usr/local/include
/usr/lib/gcc/i486-linux-gnu/4.4.3/include
/usr/include

Thanks

A: 

Do you have the proper includes?

If I remember correctly, you need to

#include <iostream>
Vnuce
Yes, it is included.
Martijn Courteaux
It's not having any problems with the include? Then you don't have a problem with the include paths, that's for sure. Try compiling it from the command line, so that we can localize the problem.
Vnuce
But it compiles without any problems. The IDE debugger think it is wrong.
Martijn Courteaux
+2  A: 

It works fine for me. I'm using NetBeans 6.8; the only undefined reference I got was for the add() function.

Can you test with a new project to see if you can reproduce the problem?

EDIT (reply):

Yep, tested on Linux. No includes added in project properties.

In the global C/C++ options I have an extra include path for C, /usr/include/i486-linux-gnu.
For C++ I have:

/usr/include/c++/4.4
/usr/include/c++/4.4/i486-linux-gnu
/usr/include/c++/4.4/backward
/usr/local/include
/usr/lib/gcc/i486-linux-gnu/4.4.3/include
/usr/lib/gcc/i486-linux-gnu/4.4.3/include-fixed
/usr/include/i486-linux-gnu
/usr/include

These are my defaults, haven't touched them. HTH I also use gcc-4.4.3 (Ubuntu 10.04).

Unknown
Do you also work with linux? If, so, can you see any diff with your include folders?
Martijn Courteaux
Pasted in the main comment for better readability.
Unknown