I am having some trouble getting my code to compile. I am just learning how to code in c++ and I’m trying the Button.pressed function to start and stop my catapult. I have figured out that it needs a callback function so I took this to mean I have to declare elsewhere a function that would contain instructions for my catapult. So, I declared a void function in robot-config.h named Cata. In my user control loop, I simply put the Button.pressed function with Cata as the callback. When I try to compile my code, the terminal tells me I have multiple declarations of Cata.
I think you should look around in your code and see if there not a motor or any variable expect the function named “Cata” that should probably be the problem
No, I have tried changing the function name, it originally was Catapult_Movement, then I tried Catapult_Pos, and then I tried something random like fleeing, but they all return the same error.
Also why are you declaring your function inside the robot configuration file? If its not important anywhere else you should delete that and just keep the function in your main.cpp
first, do not declare events inside of a while loop as this will cause the event to be registered multiple times leading to unexpected behavior. This is most likely a problem with how the function is declared and incorrect usage of function prototypes and/or header files. Here’s an example from the learncpp.com on header files
add.cpp:
int add(int x, int y)
{
return x + y;
}
main.cpp:
#include <iostream>
int add(int x, int y); // forward declaration using function prototype
int main()
{
std::cout << "The sum of 3 and 4 is " << add(3, 4) << '\n';
return 0;
}