我从mbed C++编译器收到错误消息,似乎是指示包括警卫在内的故障。C++包括警卫似乎没有工作
在main.cpp中,我包括我的头文件如下:
#include "mbed.h"
#include "sample.h"
这是我sample.h:
#include "mbed.h"
#ifndef STUFF_H
#define STUFF_H
/* LEDs */
DigitalOut led1(LED1);
DigitalOut led2(LED2);
DigitalOut led3(LED3);
DigitalOut led4(LED4);
/* Subroutines */
void sweepLEDs();
void pulseLEDs(int numPulses);
void clearLEDs();
#endif
在sample.cpp的,我包括sample.h为如下:
#include "sample.h"
在这两个的main.cpp和sample.cpp的,我指的是变量led1, led2, led3, led4
没有decla响它们。但是,编译器正在输出这些投诉:
“符号led1多次定义(由sample.cpp.cpp.LPC1768.o和main.cpp.cpp.LPC1768.o)”。 ... “符号led4乘法定义(由sample.cpp.cpp.LPC1768.o和main.cpp.cpp.LPC1768.o)”。
我的包括警卫书写不当吗?还是有其他问题?
(仅供参考,这里是link to the mbed.h source)