Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Method 'cend' could not be resolved, but build is successful
Method 'cend' could not be resolved, but build is successful [message #1732909] Sun, 22 May 2016 17:24 Go to next message
David Frager is currently offline David FragerFriend
Messages: 2
Registered: May 2016
Junior Member
I am attempting to setup Eclipse for C/C++, and I am seeing an issue when testing my configuration.

I have a very basic C++ program using vectors, and in the IDE, I see errors indicating that "Method 'cend' could not be resolved. However, If I do a build, my build is successful.

a small portion of the code is:
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <vector>

std::vector<std::string> tokenize(const std::string& s, char c) {
auto end = s.cend();
auto start = end;

std::vector<std::string> v;
for( auto it = s.cbegin(); it != end; ++it ) {
if( *it != c ) {
if( start == end )
start = it;
continue;
}
if( start != end ) {
v.emplace_back(start, it);
start = end;
}
}
if( start != end )
v.emplace_back(start, end);
return v;
}
Re: Method 'cend' could not be resolved, but build is successful [message #1732965 is a reply to message #1732909] Mon, 23 May 2016 06:21 Go to previous messageGo to next message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
You should avoid using auto to declare variables this way. It's OK for loops and function results but auto originally was a storage class (the opposite of static) . This changed with C++11. You seem to be using C++11. The compiler warns about using auto -- with C++98 anyway.

Although it's legal, sometimes the indexer gets confused by auto constructs.
using std::string::const_iterator end = s.cend(); might fix the problem..

Give it a try and let us know if it didn't.

[Updated on: Mon, 23 May 2016 12:55]

Report message to a moderator

Re: Method 'cend' could not be resolved, but build is successful [message #1733490 is a reply to message #1732965] Sat, 28 May 2016 12:35 Go to previous message
David Frager is currently offline David FragerFriend
Messages: 2
Registered: May 2016
Junior Member
Thanks for the reply and info. Forcing a re-index solved my problem
Previous Topic:Eclipse CDT for remote C++ development?
Next Topic:Include a path for system headers (-isystem)
Goto Forum:
  


Current Time: Fri Apr 26 04:11:57 GMT 2024

Powered by FUDForum. Page generated in 0.03202 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top