這幾天寫液晶字庫索引時發(fā)現(xiàn)一個問題,本來想在.h文件中這樣定義:
// ------------------ 漢字字模的數(shù)據(jù)結(jié)構(gòu)定義------------------------ //
typedef structtypFNT_GB16 // 漢字字模數(shù)據(jù)結(jié)構(gòu)
{
signed charIndex[2]; // 漢字內(nèi)碼索引
charMsk[32]; // 點(diǎn)陣碼數(shù)據(jù)
};
/////////////////////////////////////////////////////////////////////////
//漢字字模表 //
// 漢字庫: 宋體16.dot縱向取模下高位,數(shù)據(jù)排列:從左到右從上到下 //
/////////////////////////////////////////////////////////////////////////
struct typFNT_GB16 code GB_16[]= // 數(shù)據(jù)表
{
"我", 0x20,0x24,0x24,0x24,0xFE,0x23,0x22,0x20,
0xFF,0x20,0x22,0xAC,0x20,0x30,0x20,0x00,
0x00,0x08,0x48,0x84,0x7F,0x02,0x21,0x10,
0x09,0x06,0x1A,0x61,0x80,0xE0,0x00,0x00,
"們", 0x40,0x20,0xF8,0x07,0x00,0xF8,0x02,0x04,
0x08,0x04,0x04,0x04,0x04,0xFE,0x04,0x00,
0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,
0x00,0x00,0x00,0x40,0x80,0x7F,0x00,0x00
};
然后在其它c(diǎn)文件中引用提示重復(fù)定義,后來看了網(wǎng)上別人的說法,應(yīng)該這么改:
即新建一個xx.h和xx.c文件
在xx.h文件中內(nèi)容為:
// ------------------ 漢字字模的數(shù)據(jù)結(jié)構(gòu)定義 ------------------------//
typedef struct typFNT_GB16 // 漢字字模數(shù)據(jù)結(jié)構(gòu)
{
signed char Index[2]; // 漢字內(nèi)碼索引
char Msk[32]; // 點(diǎn)陣碼數(shù)據(jù)
};
extern struct typFNT_GB16 code GB_16[];
在xx.c文件中內(nèi)容為:
#include "xx.h"
/////////////////////////////////////////////////////////////////////////
// 漢字字模表 //
// 漢字庫: 宋體16.dot 縱向取模下高位,數(shù)據(jù)排列:從左到右從上到下 //
/////////////////////////////////////////////////////////////////////////
struct typFNT_GB16 code GB_16[] = // 數(shù)據(jù)表
{
"我", 0x20,0x24,0x24,0x24,0xFE,0x23,0x22,0x20,
0xFF,0x20,0x22,0xAC,0x20,0x30,0x20,0x00,
0x00,0x08,0x48,0x84,0x7F,0x02,0x21,0x10,
0x09,0x06,0x1A,0x61,0x80,0xE0,0x00,0x00,
"們", 0x40,0x20,0xF8,0x07,0x00,0xF8,0x02,0x04,
0x08,0x04,0x04,0x04,0x04,0xFE,0x04,0x00,
0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,
0x00,0x00,0x00,0x40,0x80,0x7F,0x00,0x00
};
這樣編譯通過。實(shí)際上結(jié)構(gòu)體是一種數(shù)據(jù)類型,.h文件定義了一種類型的結(jié)構(gòu)體,并聲明為extern形式允許外部調(diào)用它,而初始化codeGB_16[] 這個結(jié)構(gòu)體應(yīng)當(dāng)在.c文件中進(jìn)行。
|