|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
multiple definition Problem
I keep getting this error when ever I try to compile the attached code
"multiple definition of `global constructors keyed to FRC_userClassFactory()'" |
|
#2
|
||||
|
||||
|
Re: multiple definition Problem
You're including "RoboDefs.h" twice, once in each file.
Try just including it once, or use code like this: Code:
#ifndef RANDOM_VALUE_YOU_WONT_USE #define RANDOM_VALUE_YOU_WONT_USE ... #endif |
|
#3
|
||||
|
||||
|
Re: multiple definition Problem
I would recommend using the second method dem. mentioned - it's a good habit to get into. Basically, it checks to see if anything called RANDOM_VALUE_YOU_WONT_USE has been defined yet, via the #ifndef line - everything between it and the #endif is skipped if the symbol after it has been defined previously. If it has not been defined, it defines it (#define) and then does whatever. It helps keep code and such from being accidentally repeated. The RANDOM_VALUE_YOU_WONT_USE should be replaced with a unique and descriptive title, such as MOTOR_CLASS_SYMBOL for your motor header. One thing to be careful of - don't repeat a title, as it skip the code if it has been defined elsewhere first - (that's what it's meant to do in this case, after all
- So just name it something you know wouldn't be used again - and don't worry about it being long (you'll only be typing it twice, after all) |
|
#4
|
|||
|
|||
|
Re: multiple definition Problem
RoboDefs is shielded like you posted
Code:
#ifndef RANDOM_VALUE_YOU_WONT_USE #define RANDOM_VALUE_YOU_WONT_USE ...Code... #endif I will post my whole project (zipped) if needed EDIT: Show I protect my .cpp files too Last edited by Mr.Macdonald : 26-01-2009 at 18:52. |
|
#5
|
||||
|
||||
|
Re: multiple definition Problem
Maybe that'll help...
What's the term for the second method again? It's also good for writing your own libraries...If you want to replace something with your own version, just #define to make it exclude the other file, then #include your own changed copy. Last edited by demosthenes2k8 : 26-01-2009 at 19:20. |
|
#6
|
|||
|
|||
|
Re: multiple definition Problem
Heres the whole project, I changed a few little things to no avail.
|
|
#7
|
||||
|
||||
|
Re: multiple definition Problem
I can't find anything wrong with that...but then I don't have windriver with me either...
Anyone else get further on this? |
|
#8
|
|||
|
|||
|
Re: multiple definition Problem
The problem is that you have the following line in your RoboDefs.h
START_ROBOT_CLASS(Main); This is a macro defined in RobotBase.h (for reference). This macro should only be in your Main.cpp file, and at the bottom works. Peter Rivera Mentor, Team 662. |
|
#9
|
|||
|
|||
|
Re: multiple definition Problem
Quote:
EDIT: But inside the macro shields |
|
#10
|
|||
|
|||
|
Re: multiple definition Problem
Putting the "START_ROBOT_CLASS(Main);" in the main.cpp allowed it to compile, but now I can't get the printing to work. It seems as though my code doesn't even run.
Is there another way to write the "Main" class? |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Definition of orthogonal.... | fhobart | General Forum | 9 | 08-01-2009 12:38 |
| [FTC]: Multiple Programs or One Program with Multiple Auto Modes | kevin51292 | FIRST Tech Challenge | 4 | 02-01-2009 20:37 |
| definition of FUNCPTR | shavol | Programming | 6 | 28-12-2008 19:00 |
| Hosting multiple sites in multiple VMs | EHaskins | Website Design/Showcase | 6 | 22-12-2007 01:09 |
| multiple definition error in MCC/Linker (possible bug?) | wun | Programming | 5 | 01-04-2004 17:49 |