Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » weird class method not found error
weird class method not found error [message #1749266] Sun, 04 December 2016 23:51 Go to next message
David Balažic is currently offline David BalažicFriend
Messages: 35
Registered: February 2013
Member
Hi

I have this in a header file:
class Foo
{
public:
Foo(Foo const& other){value=other.value;}
    ~Foo(void); // hmm, the tilde looks like a minus sign in the forum editer, it is a tilde, not a syntax error

    // get value
    double getBar() const{ return value;}
    double asBar() const{ return value;}
    double toBar() const{ return value;}
    double foBar() const{ return value;}

private:
    double value; // value in meters - internal implementation detail!
}


And this in a CPP file including it:

#include <Foo.h>

void  test(Foo x){
	x.toBar();
}


This works.

But if I write x.foBar(); insted. then it fails with compile error:
Quote:
Method 'foBar' could not be resolved


Also, the ctrl-space expansion does not offer it (but offer all the others).

What could be wrong?

I use:
Eclipse IDE for C/C++ Developers

Version: Neon.1a Release (4.6.1)
Build id: 20161007-1200

with cygwin GNU compiler suite.


I tried to add a new method, but it kept failing. That is why I made it 99% like an existing working method (to rule out any typo or other error).

[Updated on: Sun, 04 December 2016 23:59]

Report message to a moderator

Re: weird class method not found error [message #1749267 is a reply to message #1749266] Sun, 04 December 2016 23:58 Go to previous messageGo to next message
David Balažic is currently offline David BalažicFriend
Messages: 35
Registered: February 2013
Member
I tried to compile the files with g++ outside of eclipse and there it works.

So apparently Eclipse borked my workspace (again).

I already tried "eclipse -clean" , but it did not help.

Should just recreate the workspace?

Is it normal that one has to do this every week?
(I use Eclipse for Java since ages (10 years) and there such problems almost never happen)
Re: weird class method not found error [message #1749273 is a reply to message #1749267] Mon, 05 December 2016 06:08 Go to previous messageGo to next message
David VavraFriend
Messages: 1415
Registered: October 2012
Senior Member
Likely the index needs to be rebuilt.
Might be a bug but try Project-->C/C++ Index-->Rebuild first.


You also have a syntax error. You need a semicolon at the end of the class definition for Foo. If this wasn't a typo in the post, it may be confusing the Indexer.

The font used for normal text in the forum make the tilde look like a minus sign at different magnifications but usually comes out OK in a code block. Probably because the font in a code block has a different aspect ratio.






Re: weird class method not found error [message #1749368 is a reply to message #1749273] Mon, 05 December 2016 21:07 Go to previous messageGo to next message
David Balažic is currently offline David BalažicFriend
Messages: 35
Registered: February 2013
Member
The missing semicolon is just because I forgot to include it in the post.

[Updated on: Mon, 05 December 2016 22:33]

Report message to a moderator

Re: weird class method not found error [message #1749541 is a reply to message #1749273] Wed, 07 December 2016 22:43 Go to previous message
David Balažic is currently offline David BalažicFriend
Messages: 35
Registered: February 2013
Member
David Vavra wrote on Mon, 05 December 2016 01:08
Likely the index needs to be rebuilt.
Might be a bug but try Project-->C/C++ Index-->Rebuild first.

Yes, that helped.
Thanks.
Previous Topic:Package downloading hangs while trying to clean build CDT from source
Next Topic:mmu / mpu unavailable
Goto Forum:
  


Current Time: Wed Jan 26 00:18:53 GMT 2022

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

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

Back to the top