我想運行的代碼具有生成文件,它顯示了錯誤:未定義的引用,而不是生成文件
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/crt1.o: In function `_start':(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status
make: *** [Nfa] Error 1
與主要功能的文件是terp.c.
與主代碼的部分()是:
#ifdef MAIN
#define ALLOCATE
#include "global.h" /*externs for Verbose*/
#define SIZE 256
PRIVATE char BUf[BSIZE] //input buffer
PRIVATE char *Pbuf=BUf; //current position in input buffer
PRIVATE char *Expr; //regular expression from command Line
...
跳過一些代碼在這裏,直到主...
void main (int argc,char *argv[])
{
int sstate; //Starting NFA state
SET *start_dfastate;//Set of starting DFA states
SET *current; //current DFA state
SET *next;
int accept; //current Dfa state is an accept
int c; //current input character
int anchor;
if (argc==2)
fprintf(stderr,"Expression is %s\n",argv[1]);
else
{
fprintf(stderr,"Usage:terp pattern < input\n");
exit(1);
}
//Compile the NFA create the initial state,and initialize the current state to the start state
Expr=argv[1];
sstate=nfa(getline);
next=newset();
ADD(next,sstate);
if (!(start_dfastate=e_closure(next,&accept,&anchor)))
{
fprintf(stderr,"Internal error:State machine is empty\n");
exit(1);
}
current=newset();
assign(current,start_dfastate);
while (c=nextchar())
{
if (next=e_closure(move(current,c),&accept,&anchor))
{
if (accept)
printbuf();
else
{
delset(current);
current=next;
continue;
}
}
delset(next);
assign(current,start_dfastate);
}
}
#endif
生成文件我使用:
顯示如何運行編譯器。您的主題提到了Makefiles,但您實際上沒有提及任何關於Makefile的內容或發佈問題主體中的任何規則。 – TypeIA
請注意'void main()'在Windows上是合法的。根據標準和所有基於Unix的系統,main()的正確返回類型是int。 –