嗨imy项目认识到不存在2倍变量的双重定义。我想通过改变我的代码并重新编译它的一些方法。atmel studio ifndef编译错误
LedMatrix7219.cpp.o:(.data.Alphaletter+0x0): multiple definition of `Alphaletter' LedController.cpp.o:(.data.Alphaletter+0x0): first defined here
LedMatrix7219.cpp.o:In function `loop' LedController.cpp.o:(.bss.arr+0x0): first defined here
LedMatrix7219.cpp.o:In function `loop' LedController.cpp.o:(.data.Alphaletter2+0x0): first defined here
collect2.exe*:error: ld returned 1 exit status
我有一个类LedController和头LettersDefinition.h
所有的头开始是这样的:
我包括一个结构,并从LetterDefinition.h到LedController枚举所以在头文件中,我需要包含LetterDefinition.h以便使某个特定符合。
#ifndef __LEDCONTROLLER_H__
#define __LEDCONTROLLER_H__
#include <Arduino.h>
#include "LettersDefinition.h"
LetterStruct finalText;
String theText="Test";
void test();
//it does some extra staff
#endif //__LEDCONTROLLER_H__
和信件定义的标题。
#ifndef LETTERSDEFINITION_H_
#define LETTERSDEFINITION_H_
#include "arduino.h"
#include <avr/pgmspace.h>
struct LetterStruct{
lettersEnum name;
uint8_t size;
uint8_t columnSize[5];
uint8_t data[18];
}Alphaletter;
#endif /* LETTERSDEFINITION_H_ */
而且从我的主要.ide文件我称之为Ledcontroller的测试功能我一个让你在上面看到的错误。测试功能只检查LetterStruct.name变量。
我.ide是一样的东西:
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Max72xxPanel.h>
#include "LedController.h"
LedController controller;
void setup()
{
//irrelevant inits
}
void loop()
{
controller.test();
delay(2000);
}
如果我删除从LedController.h中的#include“LettersDefinition.h”这个错误给它的地方是,LetterStruct未在规定的误差LedController.h这是正常的,因为我必须添加LettersDefinition.h以便定义。
你确定你不是故意的定义,作为一个类型? –
正如你看到我只是声明一个类型letterstruct结构这是我所做的一切。击中定义在letterDefinition.h – kyrpav
然后你声明这种类型的变量称为“Alphaletter”。 –