2012-01-06 21 views
0

Parser.h奇妙なコンパイラエラー

enum { PLUS, MINUS, DIVIDE, MULTIPLY, NUMBER, END } type; 

int token; 

/* parsing functions */ 
void parse_token (void); 

Parser.c

エラー

parser.c:14:6: warning: conflicting types for ‘parse_token’ [enabled by default] 
parser.c:11:2: note: previous implicit declaration of ‘parse_token’ was here 
parser.c: In function ‘parse_token’: 
parser.c:16:2: warning: passing argument 2 of ‘strchr’ makes integer from pointer without a cast [enabled by default] 
/usr/include/string.h:235:14: note: expected ‘int’ but argument is of type ‘char *’ 
parser.c:17:3: error: ‘type’ undeclared (first use in this function) 
parser.c:17:3: note: each undeclared identifier is reported only once for each function it appears in 
parser.c:17:10: error: ‘NUMBER’ undeclared (first use in this function) 
parser.c:19:2: warning: passing argument 2 of ‘strchr’ makes integer from pointer without a cast [enabled by default] 
/usr/include/string.h:235:14: note: expected ‘int’ but argument is of type ‘char *’ 
parser.c:20:10: error: ‘PLUS’ undeclared (first use in this function) 
parser.c:22:2: warning: passing argument 2 of ‘strchr’ makes integer from pointer without a cast [enabled by default] 
/usr/include/string.h:235:14: note: expected ‘int’ but argument is of type ‘char *’ 
parser.c:23:10: error: ‘MINUS’ undeclared (first use in this function) 
parser.c:25:2: warning: passing argument 2 of ‘strchr’ makes integer from pointer without a cast [enabled by default] 
/usr/include/string.h:235:14: note: expected ‘int’ but argument is of type ‘char *’ 
parser.c:26:10: error: ‘DIVIDE’ undeclared (first use in this function) 
parser.c:28:2: warning: passing argument 2 of ‘strchr’ makes integer from pointer without a cast [enabled by default] 
/usr/include/string.h:235:14: note: expected ‘int’ but argument is of type ‘char *’ 
parser.c:29:10: error: ‘MULTIPLY’ undeclared (first use in this function) 
parser.c:32:10: error: ‘END’ undeclared (first use in this function) 
parser.c: In function ‘show_error’: 
parser.c:40:2: warning: incompatible implicit declaration of built-in function ‘exit’ [enabled by default] 

私は全くbamboよオズボール。 。?:(

すべてのヘルプ

+0

parser.cの14行目と11行目はどれですか? –

+0

あなたはparser.hを含んでいますか? parser.c:17:10:エラー: 'NUMBER'は宣言されていません(この関数では最初に使用されます) –

+0

レコードのために、解析していない、[字句解析](http://en.wikipedia.org/wiki/ Lexical_analysis)。ツールはパーサーではなくレクサーです。 – Jan

答えて

5

ワンuchian Grigoreは言った)、あなたは一定の文字列にstrcat()を行うことができないことがわかるでしょう。

定数文字列は読み取り専用メモリに割り当てられ、変更することはできません。あなたがそれを修正することができたとしても、あなたはメモリ内の他のものを上書きするでしょう。

+0

+1私は 'strcat()'を見逃しました –

3

あなたのヘッダを含めていないので、翻訳単位がtypetokenの宣言について知るための方法はありません

あなたは必要です。

実装ファイルの先頭に
#include "Parser.h" 

。あなたはそれをLとして、ヘッダを含むことにより、(コンパイルするために取得