Unterminated conditional directive error?

Hey, happy holidays everyone.

I have a unterminated conditional directive error in one of my PROS header files. It’s called globals.hpp and has the declarations for my motors. I believe the error is with my header guards, but I would like to keep them if possible.

#ifndef GLOBALS_HPP // Error message shows up here

#include "main.h"

// Controller
extern pros::Controller controller;

// Motors
extern pros::Motor driveLeftFront;
extern pros::Motor driveLeftBack;
extern pros::Motor driveRightFront;
extern pros::Motor driveRightBack;

// Sensors
extern pros::ADIGyro gyro;


That looks fine (pretty much identical to mine). Maybe try #pragma once instead and see if that works. If that doesn’t fix it, it maybe could be an issue from your source file?


Including #pragma once fixed the compilation error, thanks!

If anyone knows why my header guards don’t work without the pragma statement, please let me know. It’s pretty mind boggling as it appears in every instance where I have header files.

So it seems like I’ve found the issue. In main.h, I had #include "subsystemHeaders/globals.hpp" in the section right below where it says “You can add C++ -only headers here”. I thought I needed that #include there, but it seems like that isn’t true and it only causes compilation errors.

1 Like