iccavr 怎么做一个头文件带全局变量
1.c#include "config.h"
void main(void)
{
DDRD|=(1<<1);
b=a+b;
test();
}
2.c
#include "config.h"
void test(void)
{
DDRD|=(1<<1);
a=5;
test();
}
config.h
#ifndef __config_h__
#define __config_h__
#include <iom48v.h>
#include <macros.h>
typedef unsignedcharunchar;
extern void test(void);
extern unchar a=0;
extern unchar b=0;
#endif
编译 会出问题
F:\icc\bin\imakew -f 123.mak
iccavr -c -IF:\icc\include\ -e -DATMega48-l -g -Mavr_enhanced_smallF:\C\c\wuxian\1.c
iccavr -o 123 -LF:\icc\lib\ -g -bfunc_lit:0x34.0x1000 -dram_end:0x2ff -bdata:0x100.0x2ff -dhwstk_size:16 -beeprom:1.256 -fihx_coff -S2 @123.lk
!E 2.o(19): multiple define: '_a'
!E 2.o(20): multiple define: '_b'
F:\icc\bin\imakew.exe: Error code 1
Done: there are error(s). Exit code: 1
请教各位高人,上面是我试试怎么用头文件和全局变量,不知道怎么回事,请帮忙解答,谢谢大家了 extern unchar a=0;
extern unchar b=0;
这是申明不是定义。把前面的extern去掉。
或者把后面的赋值去掉,在其他文件定义。 回复【1楼】lalapunk1983
-----------------------------------------------------------------------
是的,可以了,谢谢啊
页:
[1]