Hi, so I just downloaded PROS and this is all the code I have and it won’t build. Any suggestions?
You are attempting to create a Motor object and there are two different ways to do that.
- direct initialization ex:
pros::Motor leftDrive = pros::Motor(1);
- uniform initialization ex:
pros::Motor leftDrive{1};
Notice that example 2 uses brackets and not parentheses. You might also want to look at the PROS documentation and look at the example code. PROS C++ Motor info
Just wondering, if I were to use PROS later, do you have to recreate the motor objects for the autonomous section?
That looks like a linker error. Sometimes this can happen if you have issues with your compiler.
You could try running the command make all
in a terminal in your project directory. If that doesn’t work, you could try reinstalling the PROS toolchain.
Downgrade GCC to 8.2.1 or lower. How you do this depends on your OS.
No brackets also work
Are you on a Mac ? looks like you have the same issue as was asked about in this topic.
This is the same issue, thanks for catching that. @ everyone else in this thread:
With no brackets you wouldn’t be able to define the port the motor was in so you would have to define the port later. Without any arguments the object would use the default arguments which isn’t very helpful.
I mean “no, using normal brackets aka these ->() will also work fine.”
I understand what you mean with the {} brackets, since the compiler thought it was a function decloration with the pros::Motor return type, but using () has worked perfectly for me
Nah, this does not matter.
pros::Motor myMotor(1);
is the recommended way to create a motor object.
It does not really matter how you do it, using curly braces or using the syntax in your first option makes no difference. You are simply calling the constructor.
As to the error itself, the problem does not come from user code (or it would have shown the problem), but instead from the internals of GCC.