Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

netbeans unable to resolve identifier c_str

Tags:

c++

netbeans

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?

like image 934
CybeX Avatar asked Dec 19 '25 00:12

CybeX


1 Answers

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.

like image 97
mdewit Avatar answered Dec 21 '25 14:12

mdewit



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!