I made a new Command Based project and upon opening Robot.cpp I see two errors. One is on std::string (under the AutonomousInit function) and says “Type std::string could not be resolved.” At the very bottom, I have an error on START_ROBOT_CLASS(Robot) which says I have invalid arguments. Over in OI.cpp I have an error on “OI::OI()” which says "Member declaration not found,
" even though I can see it being declared in OI.h
This is a NEW Command Based Project. This was all done on a NEW Windows 10 Laptop with nothing installed on it except Chrome and the FRC C++ essentials. I have tried cleaning-rebuilding but the errors remain.
Thanks, that fixed the errors in OI. The errors in Robot.cpp remain, except now the START_ROBOT_CLASS(Robot) is now just a syntax error, and the std::string is the same. I’m going to try including string but I would think it would access it with std::string, unless
The way you’re trying to include the string class is a syntax error.
#include <string>
is the proper way to include it. I don’t usually trust the Eclipse indexer because it gives false positives like this so much. If the code compiles when you press the build button, ignore the indexer.
My bad, I didn’t clarify. I meant I was GOING to try including that and when I sent my reply I missed a #. At the time of the post, string wasn’t even being included. The error itself was on “std::string” (not as an import). Should I provide more of my code?
If it’s just the example with no changes, that’s fine. <string> is already included by the SmartDashboard.h header that necessitated it being used, so adding another one shouldn’t be necessary (although I guess you could argue there should be one because include-what-you-use is a style guide rule we have and one’s being used).
Regarding the error, if it’s the red squiggle underneath, that’s either the indexer or the compiler. Before posting your code, try running a build. If it succeeds, it’ll say so in the console. If not, it’ll print an error message with what caused it to fail. Which of those two it is will help us figure out if it’s an indexer issue or a problem in WPILib’s example.
I remade a project and the red error on std::string is gone. All that’s left is a syntax error on START_ROBOT_CLASS(Robot) which now that you said it earlier, I’m pretty sure it is a false positive.