mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-29 02:21:44 +00:00
Replaced the START_ROBOT_CLASS() macro with a template function (#1050)
The START_ROBOT_CLASS() macro's main() now calls this function through a deprecated proxy function to encourage users to switch.
This commit is contained in:
committed by
Peter Johnson
parent
64b03704f8
commit
c89678971c
@@ -18,18 +18,27 @@ namespace frc {
|
||||
|
||||
class DriverStation;
|
||||
|
||||
#define START_ROBOT_CLASS(_ClassName_) \
|
||||
int main() { \
|
||||
if (!HAL_Initialize(500, 0)) { \
|
||||
wpi::errs() << "FATAL ERROR: HAL could not be initialized\n"; \
|
||||
return -1; \
|
||||
} \
|
||||
HAL_Report(HALUsageReporting::kResourceType_Language, \
|
||||
HALUsageReporting::kLanguage_CPlusPlus); \
|
||||
wpi::outs() << "\n********** Robot program starting **********\n"; \
|
||||
static _ClassName_ robot; \
|
||||
robot.StartCompetition(); \
|
||||
template <class Robot>
|
||||
int StartRobot() {
|
||||
if (!HAL_Initialize(500, 0)) {
|
||||
wpi::errs() << "FATAL ERROR: HAL could not be initialized\n";
|
||||
return -1;
|
||||
}
|
||||
HAL_Report(HALUsageReporting::kResourceType_Language,
|
||||
HALUsageReporting::kLanguage_CPlusPlus);
|
||||
wpi::outs() << "\n********** Robot program starting **********\n";
|
||||
static Robot robot;
|
||||
robot.StartCompetition();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define START_ROBOT_CLASS(_ClassName_) \
|
||||
WPI_DEPRECATED("Call frc::StartRobot<" #_ClassName_ \
|
||||
">() in your own main() instead of using the " \
|
||||
"START_ROBOT_CLASS(" #_ClassName_ ") macro.") \
|
||||
int StartRobotClassImpl() { return frc::StartRobot<_ClassName_>(); } \
|
||||
int main() { return StartRobotClassImpl(); }
|
||||
|
||||
/**
|
||||
* Implement a Robot Program framework.
|
||||
|
||||
Reference in New Issue
Block a user