9

While programming in NetBeans, I downloaded all the right compilers. C worked fine for me.

But now that I started working with C++, I realized that while opening a new source file C++ with the extension .cpp the NetBeans goes to the C compilers, and then can't find include such as <iostream> etc.

But when opening the file with the extension .c++ the NetBeans does go to the right directory and does recognize everything C++ related. Is there any way to change that so that the extension .cpp will also go to the right directory? Thank You!

1 Answer 1

6

By default, NetBeans does treat .cpp files as C++ source code. The file extension mappings are configurable, so it is possible that they are different or corrupt on your machine. To change them do the following:

  1. Select Tools->Options
  2. Click the C/C++ category.
  3. Click the Other tab
  4. Verify that "cpp" is in the C++ File Extensions list. If it is missing, add it.
  5. Verify that "cpp" is not in the C File Extensions list. If it is present, remove it.
  6. Click OK
  7. Maybe restart NetBeans
Sign up to request clarification or add additional context in comments.

1 Comment

Step 5 was the important one for me, cpp was defined (somehow?) in C source file extensions. BTW, you can override the tool used by a specific file by selecting <file>->Properties from the project view and selecting the "Tool" on the General Tab - in my case the file.cpp file was pulling in the C Tool

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.