3

Good day all

I have recently switched from Qt-Creator to NetBeans, and I am regretting this decision, this is the latest (of many) issues I have had with compiler error, etc.

Previous issue and MinGW64 compiler installation

Problem:

After installing the MinGW64 compiler due to an unreasonable error I had with the std::to_string method, I have a similar issue.

Currently, I am using the MinGW64 compiler, and when attempting to use the c_str() function, I get an error

unable to resolve identifier c_str

Reparsing the project has no effect. Attempting to use auto-complete provides no suggestions aswel

Bare Minimum Code:

#include <string>    
using namespace std;

netm::netm(string hostname, int portNumber)
{
    const char * c = hostname.c_str();
}

Netbeans IDE Info:

Product Version: NetBeans IDE 8.2 (Build 201609300101)
Java: 1.8.0_112; Java HotSpot(TM) 64-Bit Server VM 25.112-b15
Runtime: Java(TM) SE Runtime Environment 1.8.0_112-b15
System: Windows 10 version 10.0 running on amd64; Cp1252; en_ZA (nb)

Any suggestions?

Community
  • 1
  • 1
CybeX
  • 2,060
  • 3
  • 48
  • 115
  • Man, if everyone just used [ed](https://en.wikipedia.org/wiki/Ed_(text_editor)) like in the old days this wouldn't be a problem. – user4581301 Dec 16 '16 at 00:21
  • @user4581301 hahaha was counting on someone saying that eventually... – CybeX Dec 16 '16 at 00:25
  • You seem to miss the difference between a compiler and an IDE. What about lib's & headers folders searching option? – Ripi2 Dec 16 '16 at 00:30
  • @Ripi2 I think you might be right, 2 questions then, 1. What do you mean by "libs and headers folders searching option" and 2. (not very important, but for info sake) why would changing compilers solve the previous problem I have been having - the linked post's issue was solved by changing the compiler. – CybeX Dec 16 '16 at 00:34
  • 2
    1) The complier must know where to find #included headers and where to find linked libraries. You must tell it. 2) It happens that some IDEs also include the compiler, and pass "automagically" the required flags for those searches. – Ripi2 Dec 16 '16 at 00:41
  • Is this any use to you? http://stackoverflow.com/questions/8478317/netbeans-and-mingw-w64 – user4581301 Dec 16 '16 at 01:42

1 Answers1

7

I found the solution to this problem through https://stackoverflow.com/a/35025731/4101876

You need to set the following: Right click on project, select properties. Under Build -> C++ Compiler, set C++ Standard to something other than default. This will remove this erroneous error.

Community
  • 1
  • 1
mdewit
  • 2,016
  • 13
  • 31
  • Works for me; setting Netbeans' code assistance from c++11 to c++14 removes the red highlight, despite `std::to_string` is proper c++11 too. – davide Mar 25 '17 at 22:46
  • I had C++ 14 standard, changed to C++ 11 and it helped. Thanks. – Kamil Feb 23 '21 at 11:06