|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
define a new class(C++)
hello, i'v been trying to define a new class of my own in c++
and i dont know why but the Windriver isnt recognizing my class.. where i need to put the H and the Cpp files? do i need to define the class in the Windriver somehow? tnanks alot |
|
#2
|
||||
|
||||
|
Re: define a new class(C++)
Quote:
Have you created a downloadable kernel module project? If so, have added the .h and .cpp file(s) to that project? If so, have you built the containing project? You haven't given enough information about what you've tried and how you went about things. |
|
#3
|
|||
|
|||
|
Re: define a new class(C++)
My code is working , i dont have any problems while downloading the code to
the robot , When you say to add the H and Cpp files , you mean copy them to the directory? or that i need to make another proccess in the WindRiver to add them? and yes , i can build my project , the Windriver isnt recognize the class unlike the Jaguar or the PWM classes for example... hope you understand... thanks anyway.. |
|
#4
|
||||
|
||||
|
Re: define a new class(C++)
Quote:
They will then become part of your project and will be compiled and linked with it. Make sure to drop the files on the top of the project -- not somewhere in the middle. The best thing to do is collapse the project so you can't see any of what's inside. That way, you can't miss with dragging and dropping. Here's a snippet from the Eclipse documentation (which should be avaliable to you by using Help->Help Contents in Workbench) Importing files Files can be imported into the Workbench either by : * dragging and dropping from the file system, or * copying and pasting from the file system, or * Using the Import wizard. Using drag and drop or copy/paste to import files relies on operating system support that is not necessarily available on all platforms. If the platform you are using does not have this support, you can always use the Import wizard. Last edited by gvarndell : 28-01-2009 at 18:29. Reason: extra info |
|
#5
|
||||
|
||||
|
Re: define a new class(C++)
Your question is still a little confusing. Do you see the files that you created in the tree on the left? If not, follow the instructions below.
If you're creating files from scratch, right click on the project and go to add new file (don't remember the exact command). This will add an empty file to your project directory. If you already created the files, you can copy them into your project directory just like you would any other file (via Windows Explorer, shell, etc). You will then need to right click on the project and go to refresh in order for the files to show up in the tree. If the files are in the source tree, does the compiler attempt to build them? If you intentionally add a syntax error does the compiler catch it? If not, check the build target in the tree (I think it's green) and check to see if it is picking up all files in your project. Are you adding a #include or forward declaration in the files that use the classes? If there are compiler errors that you are getting, it would be helpful for you to post them here. That way people will be able to help you pinpoint your problem. |
|
#6
|
|||
|
|||
|
Re: define a new class(C++)
I tried to drugg the files to the project and right , my class suddenly is being recognize by the code, but now the class i'v belt is not recognize the other classes like PWM or DigitalInput and so on (thats the errors that i get)
|
|
#7
|
||||
|
||||
|
Re: define a new class(C++)
You have transitioned from Workbench problem to basic C++ programming problem. I'll have to let others help you with that but I would suggest providing more information than you have. People tend to not help when it's too much work.
|
|
#8
|
|||
|
|||
|
Re: define a new class(C++)
Typically, there's two files, the header file and the CPP file.
Example Header Code:
// Camera.h
#ifndef CAMERA_H
#define CAMERA_H
class Camera
{
public:
void doSometing();
};
#endif
Code:
// Camera.cpp
#include "Camera.h"
void Camera::doSomething()
{
printf("Doing something...");
}
Code:
//MyRobot.cpp
#include "Camera.h"
class MyRobot : public SimpleRobot
{
/* Code ommited for simplicity */
void Autonomous()
{
Camera c();
c.doSomething();
}
};
START_ROBOT_CLASS(MyRobot);
|
|
#9
|
|||
|
|||
|
Re: define a new class(C++)
Make sure that you put in the proper include files at the top of your class source files. For example, look your example robot code as provided by WPI and look at the top of the file. There are #include files there. Make sure that you have enough includes to recognize the wpi library. The simplest is to #include "WPILib.h"
|
|
#10
|
|||
|
|||
|
Re: define a new class(C++)
i didnt put those lines
#ifndef CAMERA_H #define CAMERA_H and the #endif.. what is this macro? or its not macro? and why in the OperatorControl you access you class by typing Camera c(); and not Camera *c; c = new Camera(); ? |
|
#11
|
||||
|
||||
|
Re: define a new class(C++)
|
|
#12
|
||||
|
||||
|
Re: define a new class(C++)
Quote:
Quote:
Last edited by Dave Scheck : 29-01-2009 at 18:16. |
|
#13
|
|||
|
|||
|
Re: define a new class(C++)
I'm having a similar problem as described above. I'm trying to get the Logitech Gamepad to work with our robot. I've found the .h and .cpp files I need. I've included the .h file in the WPILib and included the reference (#include) at the top of my source program. Do I need to do something with the .cpp file? If so, what?
Windriver will build my project just fine and download it to the robot. The problem is that the robot doesn't recognize the code. It acts like there isn't anything there. The only thing I can think of is that I must be doing something wrong with the gamepad files. Please help! Thanks, Eric |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| define irswitch? | Lilor | Programming | 3 | 10-02-2008 19:21 |
| Define Happiness | Elgin Clock | Chit-Chat | 17 | 30-04-2007 21:59 |
| Define A Wedge | T3_1565 | Rules/Strategy | 18 | 11-01-2007 21:22 |
| Define FIRST | slickguy2007 | General Forum | 24 | 13-10-2006 08:24 |
| **FIRST EMAIL**/FIRST Announces New Class of Senior Mentors. | Billfred | FIRST E-Mail Blast Archive | 1 | 23-12-2004 13:32 |