未定义的对我定义的函数的引用

时间:2013-11-10 14:19:22

标签: reference undefined

当我在readTransition()函数声明中调用readDPDA()函数时,我得到linker error: undefined reference。 如何在另一个函数的声明中使用我定义的函数?

 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>

 void readTransitionRules(char * temp);
 void readDPDA(char * filename);
int main()
{
  // irrelevant
}

 void readTransitionRules(char * temp)
 {
char *tempToken;
tempToken=strtok(temp," ,:");
int i;
for(i=0; i<5; i++)
{
    printf("%s",tempToken);
    strtok(NULL," ,:");
 }
   }
 void readDPDA(char * filename)
 {
/*This function tries to open DPDA text file to read
states,alphabet,stack symbols and transition rules
of the DPDA that we will use as Word Checker.     */
extern void readTransitionRules(char * temp);

char * temp;

FILE * readerForDPDA;
readerForDPDA = fopen(filename,"r");
if(readerForDPDA!=NULL)
{
    fgets(temp,30,readerForDPDA);
    if(temp[0]=='T')
    {
        readTransitionRule(temp);
    }
}
else
{

}
}

2 个答案:

答案 0 :(得分:0)

您正在呼叫readTransitionRule,但您的功能名为readTransitionRules

您可能有关于隐式函数声明的警告。不要忽视警告。

答案 1 :(得分:0)

ReadDPDA中,您引用的是readTransitionRule,而不是您定义的readTransitionRules。你错过了s字母。