Skip to main content



      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 18:51 Go to next message
Eclipse UserFriend
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 18:59] by Moderator

Re: weird class method not found error [message #1749267 is a reply to message #1749266] Sun, 04 December 2016 18:58 Go to previous messageGo to next message
Eclipse UserFriend
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 01:08 Go to previous messageGo to next message
Eclipse UserFriend
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 16:07 Go to previous messageGo to next message
Eclipse UserFriend
The missing semicolon is just because I forgot to include it in the post.

[Updated on: Mon, 05 December 2016 17:33] by Moderator

Re: weird class method not found error [message #1749541 is a reply to message #1749273] Wed, 07 December 2016 17:43 Go to previous message
Eclipse UserFriend
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: Thu Jul 24 20:58:20 EDT 2025

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

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

Back to the top