Is there a way to seperate auton from main.cpp

I was trying to find a way to make my auton code easier to organize as a programmer. I was wondering if there was a way to somehow move the auton codeto another .cpp instead of main. I’m not a very experienced programmer so I don’t know if I am using the right terminology.

Screenshot 2023-01-08 000440

There is a way you can do this. First, move prototype definitions of your autonomous functions to an autons.h file (or whatever name you feel like). A prototype defintion just lets the compiler know that the function exists, and tells the compiler to not throw any errors when the compiler sees the function. A prototype is just a function definition without a body:

return_type function_name (parameters...);

Then, in autons.cpp, include autons.h and just put the function definitions there:

return_type function_name (parameters...){
    code....
}

Then, in main.cpp, include autons.h and you’re done.

1 Like

I do not know if your code will still work, but if you want to create a new folder under src, right click on it, and it will allow you to make a new folder. Just remember that it’s name has to end with .cpp . As I have said before, I do not know if your code will still run normally, but if it is possible, I’m sure you could find a way.

i’ll try this and see what happens