Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Novice
2,516 Views

Edison Eclipse C++ Regex does not exist

Hi,

I'm attempting to use regex_replace in my program, but when I try to do it the standard C++ way, I get errors.

I have 'using namespace std;' at the top of my file, and my code I'm trying to compile is:

//returns the output of the battery-voltage command on the edison, something like "Battery Voltage = 4010 mV\nBattery level = 68%"

std::string battery = getCmdOutput("battery-voltage");

//regex is suppose to filer out everything except the mV reading in the first line

std::regex batmVReg("(Battery\ Voltage\ =\ )|(\ mV)");

int batmV = std::regex_replace(battery, batmVReg, "\n");

It's telling me that "'regex' is not a member of std" and "function 'regex_replace' could not be resolved". Is there a different way to go about doing regex in Eclispe For Edison?

12 Replies
Highlighted
Novice
19 Views

I just enabled c++11, since I realized I needed it for other parts of my project, but the regex still isn't working.

0 Kudos
Highlighted
Employee
19 Views

Hi Keith,

How did you enable C++ 11? Did you add the flags under the G++ compiler?

Did you use this https://software.intel.com/en-us/eclipse-for-iot-troubleshooting-and-faq# How_to_set_C++11 IoT - Eclipse* for Intel® IoT Platforms Troubleshooting and FAQ | Intel® Developer Zone?

Also, which Eclipse version are you using?

Could you post the full error you are getting?

Regards,

Charlie

0 Kudos
Highlighted
Novice
19 Views

Hi Charlie,

Yes I have enabled C++11 as shown in the link you posted, but I'm not sure that it is actually working.

I found a way around using the regex, but now I'm trying to use threading and it's saying "std::thread could not be resolved". I'm using the latest Eclipse version from the download page "Luna SR2 (4.4.2)", the error Eclipse is throwning is "std::regex could not be resolved"

0 Kudos
Highlighted
Employee
19 Views

Hi Keith,

You said that you found a way around using the regex, but you also said that you are having the error message "std::regex could not be resolved" . Are you having problems with regex or is only with thread?

Regards,

Charlie

0 Kudos
Highlighted
Novice
19 Views

Hi Charlie,

Sorry, I realize I worded that strangely.

I found a way around using regex that I'm using until I can resolve this issue. The error that Eclipse is giving me when I try to use regex is "std::regex could not be resolved".

I've followed the part of the FAQ on how to enable c++11, but I believe it isn't working because when I try to use things like threading, it also tells me that std::thread can't be resolved.

I hope thats a bit clearer

0 Kudos
Highlighted
Employee
19 Views

Hi Keith,

Which # includes are you using?

# include

# include

Also, select your code.cpp in Eclipse. Then right click on it > Properties > C/C++ Build > Settings and add on "Command:" -std=c++11

Let me know if you get improvements with this.

Kind regards,

Charlie

0 Kudos
Highlighted
Employee
19 Views

Hi Keith,

Do you have updates on this?

Have you been able to use regex and C++11 on Eclipse?

Regards,

Charlie

0 Kudos
Highlighted
Novice
19 Views

CMata_Intel wrote:

Hi Keith,

Do you have updates on this?

Have you been able to use regex and C++11 on Eclipse?

Regards,

Charlie

So sorry, I totally forgot to reply!

I tried the string and regex includes, as well as adding "Command:" -std=c++11 to my code file's build settings, but none of it fixed the issue, it still says that they are not resolved.

0 Kudos
Highlighted
19 Views

possibly only an IDE but not a compiler issue? Does it compile (despite IDE messages)?

which Eclipse version do you use?

0 Kudos
Highlighted
Novice
19 Views

mhahn wrote:

possibly only an IDE but not a compiler issue? Does it compile (despite IDE messages)?

which Eclipse version do you use?

It won't compile normally, but if I force it to compile despite the errors, it just skips that part of the code when running

0 Kudos
Highlighted
Employee
19 Views

Hi Keith,

On Eclipse Luna SR2 (4.4.2) and following the steps from https://software.intel.com/en-us/eclipse-for-iot-troubleshooting-and-faq# How_to_set_C++11 IoT - Eclipse* for Intel® IoT Platforms Troubleshooting and FAQ | Intel® Developer Zone I do not have problems with the code:

# include

# include

# include

int main()

{

{

//returns the output of the battery-voltage command on the edison, something like "Battery Voltage = 4010 mV\nBattery level = 68%"

//std::string battery = getCmdOutput("battery-voltage");

//regex is suppose to filer out everything except the mV reading in the first line

std::regex batmVReg("(Battery\ Voltage\ =\ )|(\ mV)");

//int batmV = std::regex_replace(battery, batmVReg, "\n");

}

}

On step 5, check that you have the following selections:

Regards,

Charlie

0 Kudos
Highlighted
Employee
19 Views

Hi Keith,

Do you have updates on this? Have you been able to compile and run the code?

Regards,

Charlie

0 Kudos