首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

建立符号表出现 LNK2019:无法解析的外部符号 异常

2012-04-25 
建立符号表出现 LNK2019:无法解析的外部符号 错误JOB.h:typedef int Status#define ERROR -1#define OK -

建立符号表出现 LNK2019:无法解析的外部符号 错误
JOB.h:
typedef int Status; 
#define ERROR -1
#define OK -2
#define SIZE_1 10
#define SIZE_2 100

struct Tab//符号表 0 1 2好单元分别广义代表数字、标示符、其他
{
int i;
char ch[SIZE_1];
};

struct Tab_1//关键字集合
{
int i;
char ch[SIZE_1];
};

struct Tab_2//运算符集合
{
int i;
char ch[SIZE_1];
};

Status CreateTab(struct Tab T,struct Tab_1 T1,struct Tab_2 T2);//符号表的生成

JOB.cpp:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include"JOB.h"

Status CreateTab(Tab T[SIZE_2],Tab_1 T1[SIZE_2],Tab_2 T2[SIZE_2])//符号表的生成
{
int key_num_T1=0,key_num_T2=0;//key_num_T1,key_num_T2分别为关键字集合和运算符集合的长度
while(strcmp(T1[key_num_T1].ch,"")!= NULL)
key_num_T1++;
while(strcmp(T2[key_num_T2].ch,"")!= NULL)
key_num_T2++;
T=(Tab *)realloc(T,(key_num_T1+key_num_T2+3)*sizeof(Tab));
if(!T)
return ERROR; 
T[0].i=0;T[0].ch[SIZE_1]=NULL;//数字单元
T[1].i=1;T[1].ch[SIZE_1]=NULL;//标识符单元
T[2].i=2;T[2].ch[SIZE_1]=NULL;//其他单元
for(int j=0;j<key_num_T1;j++)
{
T[j+3].i=T1[j].i+3;
T[j+3].ch[SIZE_1]=T1[j].ch[SIZE_1];
}
for(int j=0;j<key_num_T2;j++)
{
T[j+key_num_T1+3].i=T2[j].i;
T[j+key_num_T1+3].ch[SIZE_1]=T2[j].ch[SIZE_1];
}
return OK;
}


JOBMain.cpp:
#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
#include"JOB.h"

void main()
{
Tab T[SIZE_2]={{0, }};
struct Tab_1 T1[SIZE_2]={{0,"main"},{1,"auto"},{2,"break"},{3,"case"},{4,"char"},{5,"const"},{6,"continue"},{7,"default"},
  {8,"do"},{9,"double"},{10,"else"},{11,"enum"},{12,"extern"},{13,"float"},{14,"for"},{15,"goto"},
  {16,"if"},{17,"int"},{18,"long"},{19,"iegister"},{20,"short"},{21,"signed"},{22,"sizeof"},{23,"static"},
  {24,"return"},{25,"struct"},{26,"switch"},{27,"typedef"},{28,"union"},{29,"unsigned"},{30,"void"},
  {31,"volatile"},{32,"while"}};
struct Tab_2 T2[SIZE_2]={{0,"+"},{1,"-"},{2,"*"},{3,"/"},
  {4,">"},{5,"<"},{6,"=="},{7,"!="},{8,">="},{9,"<="},
  {10,"!"},{11,"&&"},{12,"||"},
  {13,"="},{14,"&"},{15,"?"}};

Status status;
status=CreateTab(T[SIZE_2],T1[SIZE_2],T2[SIZE_2]);
printf("%s\n",status==OK?"OK":"ERROR");
system("pause");
}

[解决办法]
继续将main函数中

status=CreateTab(T[SIZE_2],T1[SIZE_2],T2[SIZE_2]);
=>

tatus=CreateTab(T,T1,T2);
[解决办法]

探讨
引用:

在JOB.h中的声明
Status CreateTab(struct Tab T,struct Tab_1 T1,struct Tab_2 T2);//符号表的生成
==>
改成
Status CreateTab(Tab T[SIZE_2],Tab_1 T1[SIZE_2],Tab_2 T2[SIZE_2])//符号表的生成




错误 1 err……

热点排行