mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-25 01:41:43 +00:00
Added std:: prefix to more C standard library uses (#106)
This commit is contained in:
committed by
Peter Johnson
parent
daa0260a4e
commit
cee9b2609d
@@ -116,7 +116,7 @@ void IterativeRobot::StartCompetition() {
|
||||
* ready, causing the robot to be bypassed in a match.
|
||||
*/
|
||||
void IterativeRobot::RobotInit() {
|
||||
printf("Default %s() method... Overload me!\n", __FUNCTION__);
|
||||
std::printf("Default %s() method... Overload me!\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -127,7 +127,7 @@ void IterativeRobot::RobotInit() {
|
||||
* the robot enters disabled mode.
|
||||
*/
|
||||
void IterativeRobot::DisabledInit() {
|
||||
printf("Default %s() method... Overload me!\n", __FUNCTION__);
|
||||
std::printf("Default %s() method... Overload me!\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -137,7 +137,7 @@ void IterativeRobot::DisabledInit() {
|
||||
* called each time the robot enters autonomous mode.
|
||||
*/
|
||||
void IterativeRobot::AutonomousInit() {
|
||||
printf("Default %s() method... Overload me!\n", __FUNCTION__);
|
||||
std::printf("Default %s() method... Overload me!\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -147,7 +147,7 @@ void IterativeRobot::AutonomousInit() {
|
||||
* called each time the robot enters teleop mode.
|
||||
*/
|
||||
void IterativeRobot::TeleopInit() {
|
||||
printf("Default %s() method... Overload me!\n", __FUNCTION__);
|
||||
std::printf("Default %s() method... Overload me!\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -157,7 +157,7 @@ void IterativeRobot::TeleopInit() {
|
||||
* called each time the robot enters test mode.
|
||||
*/
|
||||
void IterativeRobot::TestInit() {
|
||||
printf("Default %s() method... Overload me!\n", __FUNCTION__);
|
||||
std::printf("Default %s() method... Overload me!\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -169,7 +169,7 @@ void IterativeRobot::TestInit() {
|
||||
void IterativeRobot::DisabledPeriodic() {
|
||||
static bool firstRun = true;
|
||||
if (firstRun) {
|
||||
printf("Default %s() method... Overload me!\n", __FUNCTION__);
|
||||
std::printf("Default %s() method... Overload me!\n", __FUNCTION__);
|
||||
firstRun = false;
|
||||
}
|
||||
}
|
||||
@@ -183,7 +183,7 @@ void IterativeRobot::DisabledPeriodic() {
|
||||
void IterativeRobot::AutonomousPeriodic() {
|
||||
static bool firstRun = true;
|
||||
if (firstRun) {
|
||||
printf("Default %s() method... Overload me!\n", __FUNCTION__);
|
||||
std::printf("Default %s() method... Overload me!\n", __FUNCTION__);
|
||||
firstRun = false;
|
||||
}
|
||||
}
|
||||
@@ -197,7 +197,7 @@ void IterativeRobot::AutonomousPeriodic() {
|
||||
void IterativeRobot::TeleopPeriodic() {
|
||||
static bool firstRun = true;
|
||||
if (firstRun) {
|
||||
printf("Default %s() method... Overload me!\n", __FUNCTION__);
|
||||
std::printf("Default %s() method... Overload me!\n", __FUNCTION__);
|
||||
firstRun = false;
|
||||
}
|
||||
}
|
||||
@@ -211,7 +211,7 @@ void IterativeRobot::TeleopPeriodic() {
|
||||
void IterativeRobot::TestPeriodic() {
|
||||
static bool firstRun = true;
|
||||
if (firstRun) {
|
||||
printf("Default %s() method... Overload me!\n", __FUNCTION__);
|
||||
std::printf("Default %s() method... Overload me!\n", __FUNCTION__);
|
||||
firstRun = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,11 +36,11 @@ RobotBase::RobotBase() : m_ds(DriverStation::GetInstance()) {
|
||||
NetworkTable::SetPersistentFilename("/home/lvuser/networktables.ini");
|
||||
|
||||
FILE* file = nullptr;
|
||||
file = fopen("/tmp/frc_versions/FRC_Lib_Version.ini", "w");
|
||||
file = std::fopen("/tmp/frc_versions/FRC_Lib_Version.ini", "w");
|
||||
|
||||
if (file != nullptr) {
|
||||
fputs("2016 C++ Release 5", file);
|
||||
fclose(file);
|
||||
std::fputs("2016 C++ Release 5", file);
|
||||
std::fclose(file);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ SampleRobot::SampleRobot() : m_robotMainOverridden(true) {}
|
||||
* ready, causing the robot to be bypassed in a match.
|
||||
*/
|
||||
void SampleRobot::RobotInit() {
|
||||
printf("Default %s() method... Override me!\n", __FUNCTION__);
|
||||
std::printf("Default %s() method... Override me!\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -38,7 +38,7 @@ void SampleRobot::RobotInit() {
|
||||
* field is disabled.
|
||||
*/
|
||||
void SampleRobot::Disabled() {
|
||||
printf("Default %s() method... Override me!\n", __FUNCTION__);
|
||||
std::printf("Default %s() method... Override me!\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -49,7 +49,7 @@ void SampleRobot::Disabled() {
|
||||
* robot enters the autonomous state.
|
||||
*/
|
||||
void SampleRobot::Autonomous() {
|
||||
printf("Default %s() method... Override me!\n", __FUNCTION__);
|
||||
std::printf("Default %s() method... Override me!\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -60,7 +60,7 @@ void SampleRobot::Autonomous() {
|
||||
* each time the robot enters the teleop state.
|
||||
*/
|
||||
void SampleRobot::OperatorControl() {
|
||||
printf("Default %s() method... Override me!\n", __FUNCTION__);
|
||||
std::printf("Default %s() method... Override me!\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -71,7 +71,7 @@ void SampleRobot::OperatorControl() {
|
||||
* test mode
|
||||
*/
|
||||
void SampleRobot::Test() {
|
||||
printf("Default %s() method... Override me!\n", __FUNCTION__);
|
||||
std::printf("Default %s() method... Override me!\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -26,7 +26,7 @@ Servo::Servo(uint32_t channel) : SafePWM(channel) {
|
||||
// Assign defaults for period multiplier for the servo PWM control signal
|
||||
SetPeriodMultiplier(kPeriodMultiplier_4X);
|
||||
|
||||
// printf("Done initializing servo %d\n", channel);
|
||||
// std::printf("Done initializing servo %d\n", channel);
|
||||
}
|
||||
|
||||
Servo::~Servo() {
|
||||
|
||||
@@ -71,7 +71,8 @@ void dprintf(const char* tempString, ...) /* Variable argument list */
|
||||
filename = tempString;
|
||||
for (index = 0; index < tempStringLen; index++) {
|
||||
if (tempString[index] == ' ') {
|
||||
printf("ERROR in dprintf: malformed calling sequence (%s)\n", tempString);
|
||||
std::printf("ERROR in dprintf: malformed calling sequence (%s)\n",
|
||||
tempString);
|
||||
va_end(args);
|
||||
return;
|
||||
}
|
||||
@@ -91,40 +92,40 @@ void dprintf(const char* tempString, ...) /* Variable argument list */
|
||||
/* Extract format from argument list */
|
||||
fmt = va_arg(args, const char*);
|
||||
|
||||
vsprintf(text, fmt, args);
|
||||
std::vsprintf(text, fmt, args);
|
||||
|
||||
va_end(args);
|
||||
|
||||
/* Format output statement */
|
||||
switch (type) {
|
||||
case DEBUG_TYPE:
|
||||
sprintf(outtext, "[%s:%s@%04d] DEBUG %s\n", filename, functionName,
|
||||
line_number, text);
|
||||
std::sprintf(outtext, "[%s:%s@%04d] DEBUG %s\n", filename, functionName,
|
||||
line_number, text);
|
||||
break;
|
||||
case INFO_TYPE:
|
||||
sprintf(outtext, "[%s:%s@%04d] INFO %s\n", filename, functionName,
|
||||
line_number, text);
|
||||
std::sprintf(outtext, "[%s:%s@%04d] INFO %s\n", filename, functionName,
|
||||
line_number, text);
|
||||
break;
|
||||
case ERROR_TYPE:
|
||||
sprintf(outtext, "[%s:%s@%04d] ERROR %s\n", filename, functionName,
|
||||
line_number, text);
|
||||
std::sprintf(outtext, "[%s:%s@%04d] ERROR %s\n", filename, functionName,
|
||||
line_number, text);
|
||||
break;
|
||||
case CRITICAL_TYPE:
|
||||
sprintf(outtext, "[%s:%s@%04d] CRITICAL %s\n", filename, functionName,
|
||||
line_number, text);
|
||||
std::sprintf(outtext, "[%s:%s@%04d] CRITICAL %s\n", filename,
|
||||
functionName, line_number, text);
|
||||
break;
|
||||
case FATAL_TYPE:
|
||||
fatalFlag = 1;
|
||||
sprintf(outtext, "[%s:%s@%04d] FATAL %s\n", filename, functionName,
|
||||
line_number, text);
|
||||
std::sprintf(outtext, "[%s:%s@%04d] FATAL %s\n", filename, functionName,
|
||||
line_number, text);
|
||||
break;
|
||||
default:
|
||||
printf("ERROR in dprintf: malformed calling sequence\n");
|
||||
std::printf("ERROR in dprintf: malformed calling sequence\n");
|
||||
return;
|
||||
break;
|
||||
}
|
||||
|
||||
sprintf(filepath, "%s.debug", filename);
|
||||
std::sprintf(filepath, "%s.debug", filename);
|
||||
|
||||
/* Write output statement */
|
||||
switch (dprintfFlag) {
|
||||
@@ -133,26 +134,26 @@ void dprintf(const char* tempString, ...) /* Variable argument list */
|
||||
break;
|
||||
case DEBUG_MOSTLY_OFF:
|
||||
if (fatalFlag) {
|
||||
if ((outfile_fd = fopen(filepath, "a+")) != nullptr) {
|
||||
fwrite(outtext, sizeof(char), strlen(outtext), outfile_fd);
|
||||
fclose(outfile_fd);
|
||||
if ((outfile_fd = std::fopen(filepath, "a+")) != nullptr) {
|
||||
std::fwrite(outtext, sizeof(char), std::strlen(outtext), outfile_fd);
|
||||
std::fclose(outfile_fd);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case DEBUG_SCREEN_ONLY:
|
||||
printf("%s", outtext);
|
||||
std::printf("%s", outtext);
|
||||
break;
|
||||
case DEBUG_FILE_ONLY:
|
||||
if ((outfile_fd = fopen(filepath, "a+")) != nullptr) {
|
||||
if ((outfile_fd = std::fopen(filepath, "a+")) != nullptr) {
|
||||
fwrite(outtext, sizeof(char), strlen(outtext), outfile_fd);
|
||||
fclose(outfile_fd);
|
||||
std::fclose(outfile_fd);
|
||||
}
|
||||
break;
|
||||
case DEBUG_SCREEN_AND_FILE: // BOTH
|
||||
printf("%s", outtext);
|
||||
if ((outfile_fd = fopen(filepath, "a+")) != nullptr) {
|
||||
std::printf("%s", outtext);
|
||||
if ((outfile_fd = std::fopen(filepath, "a+")) != nullptr) {
|
||||
fwrite(outtext, sizeof(char), strlen(outtext), outfile_fd);
|
||||
fclose(outfile_fd);
|
||||
std::fclose(outfile_fd);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -187,7 +188,7 @@ float NormalizeToRange(float normalizedValue) {
|
||||
|
||||
/**
|
||||
* @brief Displays an activity indicator to console.
|
||||
* Call this function like you would call printf.
|
||||
* Call this function like you would call std::printf.
|
||||
* @param fmt The format string
|
||||
*/
|
||||
void ShowActivity(char* fmt, ...) {
|
||||
@@ -301,13 +302,13 @@ int processFile(char* inputFile, char* outputString, int lineNumber) {
|
||||
|
||||
if (lineNumber < 0) return (-1);
|
||||
|
||||
if ((infile = fopen(inputFile, "r")) == nullptr) {
|
||||
printf("Fatal error opening file %s\n", inputFile);
|
||||
if ((infile = std::fopen(inputFile, "r")) == nullptr) {
|
||||
std::printf("Fatal error opening file %s\n", inputFile);
|
||||
return (0);
|
||||
}
|
||||
|
||||
while (!feof(infile)) {
|
||||
if (fgets(inputStr, stringSize, infile) != nullptr) {
|
||||
while (!std::feof(infile)) {
|
||||
if (std::fgets(inputStr, stringSize, infile) != nullptr) {
|
||||
// Skip empty lines
|
||||
if (emptyString(inputStr)) continue;
|
||||
// Skip comment lines
|
||||
@@ -323,14 +324,14 @@ int processFile(char* inputFile, char* outputString, int lineNumber) {
|
||||
}
|
||||
|
||||
// close file
|
||||
fclose(infile);
|
||||
std::fclose(infile);
|
||||
// if number lines requested return the count
|
||||
if (lineNumber == 0) return (lineCount);
|
||||
// check for input out of range
|
||||
if (lineNumber > lineCount) return (-1);
|
||||
// return the line selected; lineCount guaranteed to be greater than zero
|
||||
stripString(inputStr);
|
||||
strcpy(outputString, inputStr);
|
||||
std::strcpy(outputString, inputStr);
|
||||
return (lineCount);
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ void AnalogGyro::InitAnalogGyro(int channel) {
|
||||
SetPIDSourceType(PIDSourceType::kDisplacement);
|
||||
|
||||
char buffer[50];
|
||||
int n = sprintf(buffer, "analog/%d", channel);
|
||||
int n = std::sprintf(buffer, "analog/%d", channel);
|
||||
impl = new SimGyro(buffer);
|
||||
|
||||
LiveWindow::GetInstance()->AddSensor("AnalogGyro", channel, this);
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
AnalogInput::AnalogInput(uint32_t channel) {
|
||||
m_channel = channel;
|
||||
char buffer[50];
|
||||
int n = sprintf(buffer, "analog/%d", channel);
|
||||
int n = std::sprintf(buffer, "analog/%d", channel);
|
||||
m_impl = new SimFloatInput(buffer);
|
||||
|
||||
LiveWindow::GetInstance()->AddSensor("AnalogInput", channel, this);
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
DigitalInput::DigitalInput(uint32_t channel) {
|
||||
char buf[64];
|
||||
m_channel = channel;
|
||||
int n = sprintf(buf, "dio/%d", channel);
|
||||
int n = std::sprintf(buf, "dio/%d", channel);
|
||||
m_impl = new SimDigitalInput(buf);
|
||||
}
|
||||
|
||||
|
||||
@@ -36,8 +36,8 @@ DoubleSolenoid::DoubleSolenoid(uint8_t moduleNumber, uint32_t forwardChannel,
|
||||
m_reversed = true;
|
||||
}
|
||||
char buffer[50];
|
||||
int n = sprintf(buffer, "pneumatic/%d/%d/%d/%d", moduleNumber, forwardChannel,
|
||||
moduleNumber, reverseChannel);
|
||||
int n = std::sprintf(buffer, "pneumatic/%d/%d/%d/%d", moduleNumber,
|
||||
forwardChannel, moduleNumber, reverseChannel);
|
||||
m_impl = new SimContinuousOutput(buffer);
|
||||
|
||||
LiveWindow::GetInstance()->AddActuator("DoubleSolenoid", moduleNumber,
|
||||
|
||||
@@ -52,7 +52,7 @@ void Encoder::InitEncoder(int32_t channelA, int32_t channelB,
|
||||
m_reverseDirection = reverseDirection;
|
||||
}
|
||||
char buffer[50];
|
||||
int n = sprintf(buffer, "dio/%d/%d", channelA, channelB);
|
||||
int n = std::sprintf(buffer, "dio/%d/%d", channelA, channelB);
|
||||
impl = new SimEncoder(buffer);
|
||||
impl->Start();
|
||||
}
|
||||
|
||||
@@ -177,7 +177,7 @@ bool IterativeRobot::NextPeriodReady() {
|
||||
* exactly 1 time.
|
||||
*/
|
||||
void IterativeRobot::RobotInit() {
|
||||
printf("Default %s() method... Overload me!\n", __FUNCTION__);
|
||||
std::printf("Default %s() method... Overload me!\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -187,7 +187,7 @@ void IterativeRobot::RobotInit() {
|
||||
* called each time the robot enters disabled mode.
|
||||
*/
|
||||
void IterativeRobot::DisabledInit() {
|
||||
printf("Default %s() method... Overload me!\n", __FUNCTION__);
|
||||
std::printf("Default %s() method... Overload me!\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -197,7 +197,7 @@ void IterativeRobot::DisabledInit() {
|
||||
* called each time the robot enters autonomous mode.
|
||||
*/
|
||||
void IterativeRobot::AutonomousInit() {
|
||||
printf("Default %s() method... Overload me!\n", __FUNCTION__);
|
||||
std::printf("Default %s() method... Overload me!\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -207,7 +207,7 @@ void IterativeRobot::AutonomousInit() {
|
||||
* called each time the robot enters teleop mode.
|
||||
*/
|
||||
void IterativeRobot::TeleopInit() {
|
||||
printf("Default %s() method... Overload me!\n", __FUNCTION__);
|
||||
std::printf("Default %s() method... Overload me!\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -217,7 +217,7 @@ void IterativeRobot::TeleopInit() {
|
||||
* called each time the robot enters test mode.
|
||||
*/
|
||||
void IterativeRobot::TestInit() {
|
||||
printf("Default %s() method... Overload me!\n", __FUNCTION__);
|
||||
std::printf("Default %s() method... Overload me!\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -229,7 +229,7 @@ void IterativeRobot::TestInit() {
|
||||
void IterativeRobot::DisabledPeriodic() {
|
||||
static bool firstRun = true;
|
||||
if (firstRun) {
|
||||
printf("Default %s() method... Overload me!\n", __FUNCTION__);
|
||||
std::printf("Default %s() method... Overload me!\n", __FUNCTION__);
|
||||
firstRun = false;
|
||||
}
|
||||
}
|
||||
@@ -243,7 +243,7 @@ void IterativeRobot::DisabledPeriodic() {
|
||||
void IterativeRobot::AutonomousPeriodic() {
|
||||
static bool firstRun = true;
|
||||
if (firstRun) {
|
||||
printf("Default %s() method... Overload me!\n", __FUNCTION__);
|
||||
std::printf("Default %s() method... Overload me!\n", __FUNCTION__);
|
||||
firstRun = false;
|
||||
}
|
||||
}
|
||||
@@ -257,7 +257,7 @@ void IterativeRobot::AutonomousPeriodic() {
|
||||
void IterativeRobot::TeleopPeriodic() {
|
||||
static bool firstRun = true;
|
||||
if (firstRun) {
|
||||
printf("Default %s() method... Overload me!\n", __FUNCTION__);
|
||||
std::printf("Default %s() method... Overload me!\n", __FUNCTION__);
|
||||
firstRun = false;
|
||||
}
|
||||
}
|
||||
@@ -271,7 +271,7 @@ void IterativeRobot::TeleopPeriodic() {
|
||||
void IterativeRobot::TestPeriodic() {
|
||||
static bool firstRun = true;
|
||||
if (firstRun) {
|
||||
printf("Default %s() method... Overload me!\n", __FUNCTION__);
|
||||
std::printf("Default %s() method... Overload me!\n", __FUNCTION__);
|
||||
firstRun = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,12 +29,12 @@ PWM::PWM(uint32_t channel) {
|
||||
char buf[64];
|
||||
|
||||
if (!CheckPWMChannel(channel)) {
|
||||
snprintf(buf, 64, "PWM Channel %d", channel);
|
||||
std::snprintf(buf, 64, "PWM Channel %d", channel);
|
||||
wpi_setWPIErrorWithContext(ChannelIndexOutOfRange, buf);
|
||||
return;
|
||||
}
|
||||
|
||||
sprintf(buf, "pwm/%d", channel);
|
||||
std::sprintf(buf, "pwm/%d", channel);
|
||||
impl = new SimContinuousOutput(buf);
|
||||
m_channel = channel;
|
||||
m_eliminateDeadband = false;
|
||||
|
||||
@@ -24,7 +24,7 @@ Relay::Relay(uint32_t channel, Relay::Direction direction)
|
||||
: m_channel(channel), m_direction(direction) {
|
||||
char buf[64];
|
||||
if (!SensorBase::CheckRelayChannel(m_channel)) {
|
||||
snprintf(buf, 64, "Relay Channel %d", m_channel);
|
||||
std::snprintf(buf, 64, "Relay Channel %d", m_channel);
|
||||
wpi_setWPIErrorWithContext(ChannelIndexOutOfRange, buf);
|
||||
return;
|
||||
}
|
||||
@@ -32,7 +32,7 @@ Relay::Relay(uint32_t channel, Relay::Direction direction)
|
||||
m_safetyHelper = std::make_unique<MotorSafetyHelper>(this);
|
||||
m_safetyHelper->SetSafetyEnabled(false);
|
||||
|
||||
sprintf(buf, "relay/%d", m_channel);
|
||||
std::sprintf(buf, "relay/%d", m_channel);
|
||||
impl = new SimContinuousOutput(buf); // TODO: Allow two different relays
|
||||
// (targetting the different halves of a
|
||||
// relay) to be combined to control one
|
||||
|
||||
@@ -28,7 +28,7 @@ Solenoid::Solenoid(uint32_t channel) : Solenoid(1, channel) {}
|
||||
*/
|
||||
Solenoid::Solenoid(uint8_t moduleNumber, uint32_t channel) {
|
||||
char buffer[50];
|
||||
int n = sprintf(buffer, "pneumatic/%d/%d", moduleNumber, channel);
|
||||
int n = std::sprintf(buffer, "pneumatic/%d/%d", moduleNumber, channel);
|
||||
m_impl = new SimContinuousOutput(buffer);
|
||||
|
||||
LiveWindow::GetInstance()->AddActuator("Solenoid", moduleNumber, channel,
|
||||
|
||||
Reference in New Issue
Block a user