Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   C/C++ (http://www.chiefdelphi.com/forums/forumdisplay.php?f=183)
-   -   Problem with WPI Library (http://www.chiefdelphi.com/forums/showthread.php?t=140468)

Yanglin501st 12-20-2015 03:56 PM

Problem with WPI Library
 
Hello, a few days ago I downloaded the the WPI library into my eclipse and tried initializing a CANTalon. However, I got an error and I'm unsure of what it means and how to fix it.
Code:

class Robot: public IterativeRobot
{
public:
        LiveWindow *lw;
        CANTalon Motor(1);
        void RobotInit()
        {
                lw = LiveWindow::GetInstance();
        }

When I hovered over the error on "class Robot: public IterativeRobot", it displayed this:
"Multiple markers at this line
- candidates are:
- no matching function for call to 'CANTalon::CANTalon()'
- 'Robot::Robot()' is implicitly deleted because the default definition would be ill-formed:"

euhlmann 12-20-2015 04:06 PM

Re: Problem with WPI Library
 
Quote:

Originally Posted by Yanglin501st (Post 1513770)
Hello, a few days ago I downloaded the the WPI library into my eclipse and tried initializing a CANTalon. However, I got an error and I'm unsure of what it means and how to fix it.
Code:

class Robot: public IterativeRobot
{
public:
        LiveWindow *lw;
        CANTalon Motor(1);
        void RobotInit()
        {
                lw = LiveWindow::GetInstance();
        }

When I hovered over the error on "class Robot: public IterativeRobot", it displayed this:
"Multiple markers at this line
- candidates are:
- no matching function for call to 'CANTalon::CANTalon()'
- 'Robot::Robot()' is implicitly deleted because the default definition would be ill-formed:"

Try rebuilding the C++ Index. Right click on your project > index > rebuild

ozrien 12-20-2015 06:09 PM

Re: Problem with WPI Library
 
Also I'm not sure that is valid C++ (unless C++11 allows constructor params to be specified like that now and I didn't know).

Try to follow the example in the Talon SRX Software Reference manual section 3.4.
http://www.ctr-electronics.com/contr...ical_resources
...and since you are using CANTalons, you probably should look through the manual for help and examples.

Yanglin501st 12-21-2015 10:43 PM

Re: Problem with WPI Library
 
Quote:

Originally Posted by euhlmann (Post 1513776)
Try rebuilding the C++ Index. Right click on your project > index > rebuild

^I tried rebuilding the C++ Index like you said and nothing changed.

Quote:

Originally Posted by ozrien (Post 1513795)
Also I'm not sure that is valid C++ (unless C++11 allows constructor params to be specified like that now and I didn't know).

Try to follow the example in the Talon SRX Software Reference manual section 3.4.
http://www.ctr-electronics.com/contr...ical_resources
...and since you are using CANTalons, you probably should look through the manual for help and examples.

^I went through the reference manual and tried to mimic the example code provided. As a result, it fixed the current error but I now have yellow squiggly underline under a part of my code and I'm not sure what it means.

Code:

class Robot: public IterativeRobot
{
        CANTalon motor;
        Joystick joy;
        LiveWindow *lw;

public:
        Robot () : motor(1),
                        joy(1)
        {
        }

        void RobotInit()
        {
                lw = LiveWindow::GetInstance();
        }

        void TeleopPeriodic()
        {
                double leftAxis = joy.GetY(Joystick::kLeftHand);
                motor.Set(leftAxis);
        }

        void TestPeriodic()
        {
                lw->Run();
        }
};

This was what it displayed:
"Multiple markers at this line
- Line breakpoint: Robot.cpp [line: 8]
- Member 'lw' was not initialized in this
constructor"

Thanks for the help so far, I've only programmed Java for a year and I'm still trying to understand C++ for this year's robot!

ozrien 12-21-2015 11:16 PM

Re: Problem with WPI Library
 
euhlmann wasn't wrong, it's a good idea to reindex when creating a new project so eclipse IDE knows to look at the latest WPILIB headers for IDE features that require it. Sometimes you will get parser errors because the index'd info is stale, but they look like real compiler-errors (red lines).

Yellow lines are warnings, red lines are errors.

EclipseCDT sometimes keep old errors/warnings around after you fix them. Once in a while I will go the project explorer, expand Binaries, and delete FRCUserProgram (this is the binary you are building). Then select all the warning and errors in the Problem tab and delete them. Then full build the project. This will cleanly update the errors/warnings. If FRCUserProgram comes back in the project explorer, then you're program built successfully.
http://www.chiefdelphi.com/forums/sh...63&postcount=5

The Console window also shows latest error output from the compiler, this streams the actual output of the compiler. The problems tab is the IDE's attempt to parse the output of the last build attempt (but it tends to forgot to clear sometimes).

Your latest looks good, compiles on my side.

RufflesRidge 12-21-2015 11:43 PM

Re: Problem with WPI Library
 
Quote:

Originally Posted by Yanglin501st (Post 1514101)
This was what it displayed:
"Multiple markers at this line
- Line breakpoint: Robot.cpp [line: 8]
- Member 'lw' was not initialized in this
constructor"

The second bullet here is a warning. When you use an an initializer list like this, the IDE expects you to initialize all of the members of the class. The compiler is telling you that you are not initializing the LiveWindow pointer. You can either ignore this warning or initialize the pointer to null (you should not initialize it using LiveWindow::GetInstance, that call has to stay in RobotInit)


All times are GMT -5. The time now is 10:48 AM.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi