PROS | undeclared identifier |

I’m new to PROS and super confused about why this isn’t working.
I have this header file in main.h and this header file.
#include "subsystemheaders/drive.hpp"
This includes my method called setDriveMotors.

#include "main.h"

//HELPER FUNCTIONS

void setDrive(); 

//DRIVER CONTROL FUNCTIONS

void setDriveMotors();

Finally in my opcontrol.cpp file it says that setDriveMotors isnt defined anywhere.

#include "main.h"



void opcontrol() {

  while(true) {
    //some code to control the drive
    
    setDriveMotors();
    
    pros::delay(10);
  }
}

Heres the code in drive.cpp if you want to look.

#include "main.h"

// HELPER FUNCTIONS

void setDrive(int left, int right) {

  frontLeftD = left ;
  frontRightD = right ;
  backLeftD = left ;
  backLeftD = right ;

}

//DRIVER CONTROL FUNCTIONS

void setDriveMotors() {

  int leftJoystick = controller.get_analog(pros::E_CONTROLLER_ANALOG_LEFT_Y);
  int rightJoystick = controller.get_analog(pros::E_CONTROLLER_ANALOG_RIGHT_Y);
  if(abs(leftJoystick) < 10) {
   leftJoystick = 0;
  }
  if(abs(rightJoystick) < 10) {
    rightJoystick = 0;
  }
  setDrive(leftJoystick, rightJoystick);
}

I’m just trying to get used to coding in PROS right now so nothing is exact to a robot.

Do you #include "subsystemheaders/drive.hpp" (which I assume is that first snippet) in opcontrol.cpp?

1 Like

No, I included it in main.h though. I included main.h in opcontrol.cpp but no drive.hpp directly.

EDIT : this is part of main.h

void autonomous(void);
void initialize(void);
void disabled(void);
void competition_initialize(void);
void opcontrol(void);
#ifdef __cplusplus
}
#endif

#ifdef __cplusplus

#include "subsystemheaders/drive.hpp"
#include "subsystemheaders/globals.hpp"

//#include <iostream>
#endif

#endif  // _PROS_MAIN_H_

Hmm, and __cplusplus is definitely defined elsewhere so that subsystemheaders/drive.hpp actually gets included?

A .zip of your project might be helpful.

3 Likes

NewProject.zip (17.3 MB) Here tell me what you find.

Your project compiles fine for me.

Make sure the linter isn’t fooling you:

9 Likes

Oh thanks for the help then lol.