2012-09-30 27 views
1

input.c文件:主要看不到我的功能input.h

#include "input.h" 
void file_processing(FILE *course_file, FILE *student_file) 
{ 
    char buf[256], line[256]; 
    ........ 
} 

input.h文件:

#ifndef STUDENT_H 
#define STUDENT_H 

#include <string.h> 

void process_command(char command[256]); 

void file_processing(FILE *course_file, FILE *student_file); 

#endif 

main.c文件:

#include "input.h" 

int main(int argc, char *argv[]){ 
    ......... 
    file_processing(course_file, student_file); 
    ... 
    return 0; 
} 

編譯器扔我這個錯誤:

main.c: In function ‘int main(int, char**)’: 
main.c:53:46: error: ‘file_processing’ was not declared in this scope 

任何人都可以給我一些提示什麼看?

更新: 經過一些額外的編碼,我收到了一個不同的錯誤。

/tmp/ccJ4nsnm.o: In function `main': 
main.c:(.text+0x1e5): undefined reference to `file_processing(_IO_FILE*, _IO_FILE*)' 
collect2: ld returned 1 exit status 
+1

你正在使用什麼編譯器 - 如果是gcc,你可以使用'-E'選項給你一些線索如何預處理器讀取你的代碼 –

+1

'input.h'文件在'main。 c'是?如果沒有,你是否指定編譯器在哪裏尋找頭文件? – Mahesh

+0

我使用gcc,並使用-E,input.h只出現一次(#1「input.h」1)並沒有其他出現。它在同一個目錄中。 – rlhh

回答

4

我覺得有趣的是你的多重保護列入不匹配文件名:

你收到從另一個.h文件中說的也是被列入?

+0

哦,是的,你說得對。該死的,不知道我是如何錯過的。 :p – rlhh

+0

@ user1043625:可能是複製/粘貼錯誤。隨時都會發生。 –

+0

@FredLarson我是否錯過了一些愚蠢的東西,爲什麼它必須匹配(除了良好的編碼標準) –