51中sbit型的变量相当于是宏,因此在一个.c文件中定义了该宏,如果想在别的.c文件中使用,就需要重新定义。

也可以定义在头文件中,使用include指令包含定义的宏(sbit 变量)。

下面是一个demo

my.c

#include "my.h"

//char bdata t1 _at_ 0x20;

void test()

{

t1_7=0;

}my.h

#ifndef __my_h__

#define __my_h__

#include

char bdata t1 ;//_at_ 0x20;

sbit t2=P1^0;

sbit t1_7=t1^7;

extern void test();

#endiftest.c#include

#include "my.h"

main()

{

while(1)

{

t2=~t2;

t1_7=~t1_7;

test();

}

}