I'm currently developing a project which involves 7 files: main.cpp
, GpioInterface.h
, GpioInterface.cpp
, Utility.h
and Utility.cpp
.
Basically in the main.cpp
file I declare the board type using #define BOARD_TYPE WHATEVER
and then in GpioInterface.h
I define some values if this macro has been defined.
It looks something like this:
main.cpp:
#define __USE_BOARD_ WHATEVER // This should go in an external file in the future
#ifdef __USE_BOARD_
// Define some stuff
#endif
#include "GpioInterface.h"
#include "Utility.h"
// main function here
GpioInterface.h:
#ifndef GPIO_INTERFACE_H
#define GPIO_INTERFACE_H
#include <stdint.h>
#include <stdio.h>
#ifdef __USE_BOARD_
enum GPIO_PIN_MODE {
GPIO_PIN_MODE_OUTPUT = 0x00,
GPIO_PIN_MODE_INPUT = 0x01,
};
enum GPIO_PIN_STATE {
GPIO_PIN_STATE_LOW = 0x00,
GPIO_PIN_STATE_HIGH = 0x01,
};
#endif // __USE_BOARD_
// some other stuff
#endif // GPIO_INTERFACE_H
Utility.cpp:
#include "Utility.h"
#include "GpioInterface.h"
void someFunction() {
GPIO_digitalWrite(2, GPIO_PIN_STATE_HIGH); // Write HIGH in pin 2
}
When compiling, the GpioInterface.h
file is giving me the following error 'GPIO_PIN_STATE_HIGH' was not declared in this scope
.
Any idea how to make the enums defined in GpioInterface.h
visible to Utility.cpp
?
Thanks!