Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Could not be resolved(Various items could not be resolved by eclipse mars)
Could not be resolved [message #1720501] Tue, 19 January 2016 05:10 Go to next message
Dan Berry is currently offline Dan BerryFriend
Messages: 6
Registered: January 2016
Junior Member
I have a class using the chrono library and I am getting several "could not be resolved" errors.

Here is the section of code that is giving me the errors.

#include "Ultrasonic.h"
#include <bcm2835.h>
#include <chrono>
#include <iostream>

using namespace std;
using duration_cast;
using microseconds;
using steady_clock;


Ultrasonic::Ultrasonic(int TP, int EP)
{
int wiringPiSetup(void);

bcm2835_gpio_fsel(TP, BCM2835_GPIO_FSEL_OUTP);
bcm2835_gpio_fsel(EP, BCM2835_GPIO_FSEL_INPT);
Trig_pin=TP;
Echo_pin=EP;
duration=0;
distance_cm=0;
distance_inc=0;


}

long Ultrasonic::Timing()
{

bcm2835_gpio_write(Trig_pin, LOW);
delayMicroseconds(2);
bcm2835_gpio_write(Trig_pin, HIGH);
delayMicroseconds(10);
bcm2835_gpio_write(Trig_pin, LOW);

while(bcm2835_gpio_lev(Echo_pin) == LOW);

steady_clock::time_point start = steady_clock::now();
while(bcm2835_gpio_lev(Echo_pin) == HIGH);
steady_clock::time_point end = steady_clock::now();

return duration_cast<microseconds>(end - start).count();

}


I have the libraries called out and I see them in the include section of the project explorer.

Any Ideas?

Shocked The issues of a newbie
Re: Could not be resolved [message #1720559 is a reply to message #1720501] Tue, 19 January 2016 10:13 Go to previous messageGo to next message
Dan Berry is currently offline Dan BerryFriend
Messages: 6
Registered: January 2016
Junior Member
I should say that the issues are with the chrono functions.
Re: Could not be resolved [message #1720601 is a reply to message #1720559] Tue, 19 January 2016 16:50 Go to previous messageGo to next message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
The short answer is because CDT can't read red code. Smile Seriously though, you need to be specific about the errors you are seeing. Just dumping your code here isn't very helpful. I wonder why you would. I hope you aren't asking us to fix your code. This forum is for CDT issues.

Which it might be. This is a favorite and frequently asked question. Eclipse needs to be told where the libraries are and also which dialect is being used (say C++11, required for the chrono library BTW) among other things. Rather than play twenty questions, though, why don't you:
- tell/show us the specific problem
- what steps you've taken to fix it
- specifics about your installation and project (Eclipse and CDT versions; project type)

EDIT:
Hopefully to make the cycle shorter, I'm guessing you didn't tell the Indexer that you are using C++11 which is required for std::chrono. The place for this is in Project ==> Properties ==> C/C++ General ==> Preprocessor Paths, Macros etc in the Providers tab under the appropriate compiler builtin.

The discovery command has to be changed to ${COMMAND} -std=c++0x -E -P -v -dD ${INPUTS} assuming the compiler is GCC. The reason is that predefined macros take on different values depending on the standard being used. You can do this globally or by project. After this, the best thing to do is select Allocate Console ... and hit Apply as it apparently doesn't always automatically re-run. You can disable the console output after this.

You also need to modify the tool chain compiler settings for C+11 for generating make a make file but that is a different matter.

[Updated on: Tue, 19 January 2016 22:33]

Report message to a moderator

Re: Could not be resolved [message #1720763 is a reply to message #1720601] Wed, 20 January 2016 17:37 Go to previous messageGo to next message
Dan Berry is currently offline Dan BerryFriend
Messages: 6
Registered: January 2016
Junior Member
To further elaborate on my issue;
I am using Eclipse Mars.1 release 4.5.1 in a CDT cross compile development for a Raspberry Pi v 4.1.13-v7+. Eclipse is installed on a Ubuntu 14.04 LTS computer. I have the cross compiler arm-linux.gnueabihf-g++ ver 4.8.2 installed, and all other packages installed and up to date.

I have added the following to the project properties C/C++ Build, Settings this prefix arm-linux-gnueabihf- and the path; /usr/lib/gcc-cross/arm-linuxgnueabihf/4.8.2

From there I have added and removed includes in the Cross G++ Compiler includes and Linker libraries and library search paths.

I have also added in eclipse in the windows, preferences, C++, Build, setting, under the Discovery tab, on the "CDT Cross Gcc Built-in Compiler Settings" the discovery command, instructions outlined by "David Vavra" so that I could do a variety of things without resetting it every time I created a new project.

I am still getting "Function 'now' could not be resolved error.

I am also looking at the Youtube video by Bo Quan tutorial on "C++11 library :Clocks and Timers"
Re: Could not be resolved [message #1721030 is a reply to message #1720763] Fri, 22 January 2016 17:09 Go to previous messageGo to next message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
The Indexer doesn't handle implied multiple levels of namespaces very well.
Recommend typedefs and macros if you don't like typing long names.

index.php/fa/24725/0/

[Updated on: Fri, 22 January 2016 17:30]

Report message to a moderator

Re: Could not be resolved [message #1721189 is a reply to message #1721030] Mon, 25 January 2016 15:04 Go to previous messageGo to next message
Marc-André Laperle is currently offline Marc-André LaperleFriend
Messages: 256
Registered: July 2009
Senior Member
David Vavra wrote on Fri, 22 January 2016 12:09
The Indexer doesn't handle implied multiple levels of namespaces very well.
Recommend typedefs and macros if you don't like typing long names.

index.php/fa/24725/0/


Could you report a bug about this (or link to an existing one)? I think this should work.
Re: Could not be resolved [message #1721223 is a reply to message #1721189] Mon, 25 January 2016 21:10 Go to previous message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
Actually it's not a bug. I very rarely employ using statements and consider them bad practice. Because of this, I read what I wanted to see and missed the error.

Which is: the statement should be "using namespace std::chrono" vs. "using std::chrono".
The various forms of using are listed here with a brief description.
http://en.cppreference.com/w/cpp/language/namespace

Something that works:
index.php/fa/24745/0/

Note that std::chrono::steady_clock is NOT a namespace. It's a structure. I didn't pick up on the color difference clue in using std::chrono::steady_clock.

The line time_point tp = now(); contains two compiler errors

error: invalid use of template-name 'std::chrono::time_point' without an argument list
error: 'now' was not declared in this scope

As for acceptability and why using statements aren't a good idea:
http://stackoverflow.com/questions/1452721/why-is-using-namespace-std-considered-bad-practice

Nothing worse than being handed code written by someone else and trying to guess which function was meant to be used. Far better to place the namespace qualifiers or even the fully qualified function name in a macro and use the macro. YMMV

EDIT:
I should mention that the error invalid use of template-name 'std::chrono::time_point' ... illustrates one of the dangers of employing using statements. Note that time_point is ambiguous. In this case, the compiler generated an error message. Imagine how long it would take to track down this problem if the build succeeds. Using statements are just lazy.and uncalled for (/rant)

[Updated on: Mon, 25 January 2016 23:08]

Report message to a moderator

Previous Topic:Assembly code error with Cygwin toolchain
Next Topic:Helping the indexer
Goto Forum:
  


Current Time: Tue Apr 23 15:35:49 GMT 2024

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

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

Back to the top