Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Function can't be resolved error
Function can't be resolved error [message #1000196] Mon, 14 January 2013 08:39 Go to next message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
I tried making a makefile project from existing code. When I edit, I constantly get errors indicating that the include files weren't recognized (such as: Function can't be resolved). So, I figured I'd make a corresponding Hello World project using the wizard to see the "right" way. I get the same problem from the very beginning.

There are no error flags on the include files so I assume they are being found. It just seems they aren't being considered.

Is there something special I need to do to make this work? I've tied searching for similar problems but only found non-applicable ones or those with no answers. This is very puzzling and I'd hate to have to convert what I have to individual projects.

DAV

#include <stdio.h>
#include <stdlib.h>

int main(void) {
puts("Hello World!!!");
return EXIT_SUCCESS;
}


Description Resource Path Location Type
Function 'puts' could not be resolved Hello.cpp /Hello line 13 Semantic Error

[Updated on: Mon, 14 January 2013 08:45]

Report message to a moderator

Re: Function can't be resolved error [message #1000382 is a reply to message #1000196] Mon, 14 January 2013 16:18 Go to previous messageGo to next message
Cong Chen is currently offline Cong ChenFriend
Messages: 7
Registered: January 2013
Junior Member
did you try other functions in the header file?
is it a cpp or .c file?
Re: Function can't be resolved error [message #1000517 is a reply to message #1000382] Mon, 14 January 2013 23:25 Go to previous messageGo to next message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
It's the output from a wizard for making a C++ Hello World executable project. Directly out of the box without any modifications. Just stepped through the wizard and poked "finish".

I modified my original (that is created a new project) letting eclipse take over control of the makefile and for whatever reason it picks on something included from a package where the headers are installed in /usr/local/include. It will compile and link just fine but it always flags calls on anything that refers to those headers.I can clear them but they pop right back if I try running the debugger or modify any of the files.

So, either I managed to turn something off somehow (quite likely) or Eclipse is broken.

If I can't get a resolution maybe I can get a hint on turning off the flags as they are bogus. It's a nice feature but I can't deal with a page full of meaningless flags that hide the real ones.



Re: Function can't be resolved error [message #1000559 is a reply to message #1000517] Tue, 15 January 2013 01:45 Go to previous messageGo to next message
John LaLuna is currently offline John LaLunaFriend
Messages: 4
Registered: September 2011
Junior Member
I'm having similar problems, but probably not for the same reasons.

Function 'Sleep' could not be resolved	main.cpp	/sfmltest	line 22	Semantic Error
Invalid overload of 'endl'	main.cpp	/sfmltest	line 21	Semantic Error
Method 'GetElapsedTime' could not be resolved	main.cpp	/sfmltest	line 19	Semantic Error
Method 'GetElapsedTime' could not be resolved	main.cpp	/sfmltest	line 21	Semantic Error
Type 'sf::Clock' could not be resolved	main.cpp	/sfmltest	line 18	Semantic Error

#include <SFML/System.hpp>
#include <iostream>
//#include <iomanip>

using namespace std;

int main()
{
    sf::Clock Clock;
    while (Clock.GetElapsedTime() < 5.f)
    {
        cout << Clock.GetElapsedTime() << endl;
        sf::Sleep(0.5f);
    }

    return 0;
}

I'm attempting to configure SFML to work with Eclipse.

What's funny is that it does compile and link and I can run the executable from the Debug folder and it works exactly as it should, but I still get these errors, and in the editor it shows errors and red underlines in the code.

I've been using Eclipse CDT for the last 2 years at school, but this is the first time I've tried to use an external library.

[Updated on: Tue, 15 January 2013 01:46]

Report message to a moderator

Re: Function can't be resolved error [message #1000769 is a reply to message #1000559] Tue, 15 January 2013 12:09 Go to previous messageGo to next message
Axel Mueller is currently offline Axel MuellerFriend
Messages: 1973
Registered: July 2009
Senior Member
John LaLuna wrote on Tue, 15 January 2013 02:45
I'm having similar problems, but probably not for the same reasons.

Function 'Sleep' could not be resolved	main.cpp	/sfmltest	line 22	Semantic Error
Invalid overload of 'endl'	main.cpp	/sfmltest	line 21	Semantic Error
Method 'GetElapsedTime' could not be resolved	main.cpp	/sfmltest	line 19	Semantic Error
Method 'GetElapsedTime' could not be resolved	main.cpp	/sfmltest	line 21	Semantic Error
Type 'sf::Clock' could not be resolved	main.cpp	/sfmltest	line 18	Semantic Error

#include <SFML/System.hpp>
#include <iostream>
//#include <iomanip>

using namespace std;

int main()
{
    sf::Clock Clock;
    while (Clock.GetElapsedTime() < 5.f)
    {
        cout << Clock.GetElapsedTime() << endl;
        sf::Sleep(0.5f);
    }

    return 0;
}

I'm attempting to configure SFML to work with Eclipse.

What's funny is that it does compile and link and I can run the executable from the Debug folder and it works exactly as it should, but I still get these errors, and in the editor it shows errors and red underlines in the code.

I've been using Eclipse CDT for the last 2 years at school, but this is the first time I've tried to use an external library.

These are not build errors (from the compiler) but "semantic errors". The internal code analyzer (CODAN) creates them. CODAN depends on the CDT index that represents the structure of your source code with all declarations, definitions etc. (the index is used e.g. to get code completion, jump to to the declaration/definition with the key F3 etc.)
In your case it looks like the index is not complete. You should add the include paths for your external library to Project Properties->C/C++ general->Paths and Symbols and then rebuild the index (from the project's context menu).



Before you ask
- search this forum
- see the FAQ http://wiki.eclipse.org/CDT/User/FAQ
- google
Re: Function can't be resolved error [message #1000897 is a reply to message #1000769] Tue, 15 January 2013 16:38 Go to previous messageGo to next message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
John is getting the same errors as I am. It also doesn't explain why the example I posted above exhibits similar problems. In my case, the includes are already in the include path.

I've attached a typical error and a snap of the includes list. I'm at a loss as to what else can be done.

BTW: notice the "/usr/local/unclude"? I had misspelled "include" when I added the path as you suggested. I subsequently edited the entry but now there's an entry I'm not allowed to delete.


UPDATE: The undeletable path was cute at first but it's beginning to be annoying. I can't compile because its not a valid path. I can't delete it because it's greyed out. It's not being kept in the .cproject file with the rest of the includes I've added yet I can export it. ARRGH! So, maybe the problem with the Code Analysis is because there are apparently multiple lists of include files (which IMO is not very good design)?

UPDATE2: Well, I found the phantom include in the g++ command lines contained in the *.sc and *_scd.mk files. After I edited those, the "unclude" disappeared. Something else to add to the test suite assuming there is one.


[Updated on: Tue, 15 January 2013 18:30]

Report message to a moderator

Re: Function can't be resolved error [message #1000909 is a reply to message #1000897] Tue, 15 January 2013 17:07 Go to previous messageGo to next message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
I turned off the last four boxes in the Code Analysis dialog (see below). Not the best solution but at least it got rid of the annoying, incorrect flags. Perhaps someone will come up with a better solution.

  • Attachment: codeanal.png
    (Size: 10.51KB, Downloaded 871 times)
Re: Function can't be resolved error [message #1001037 is a reply to message #1000769] Tue, 15 January 2013 22:28 Go to previous message
John LaLuna is currently offline John LaLunaFriend
Messages: 4
Registered: September 2011
Junior Member
Axel Mueller wrote on Tue, 15 January 2013 07:09
These are not build errors (from the compiler) but "semantic errors". The internal code analyzer (CODAN) creates them. CODAN depends on the CDT index that represents the structure of your source code with all declarations, definitions etc. (the index is used e.g. to get code completion, jump to to the declaration/definition with the key F3 etc.)
In your case it looks like the index is not complete. You should add the include paths for your external library to Project Properties->C/C++ general->Paths and Symbols and then rebuild the index (from the project's context menu).


The path to the external library was already included, but I faux edited it and pressed Apply which resulted in a popup asking to rebuild the index. Once that was done the "semantic" errors went away. Curiously this resulted in another minor problem. lol. When I attempt to RUN the program it gets rebuilt and claims that the #includes no longer exist. "fatal error: SFML/Audio.hpp: No such file or directory main.cpp /sfmltest line 8 C/C++ Problem"

It's a minor problem that I can live with, but annoying. I can build it, and the executable does work as intended.
Previous Topic:Compling problems with new subdirs
Next Topic:copy Cygwin Toolchain
Goto Forum:
  


Current Time: Fri Mar 29 06:11:22 GMT 2024

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

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

Back to the top