1

input.c文件:

#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
4

1 回答 1

4

我发现您的多重包含保护与您的文件名不匹配很有趣:

#ifndef STUDENT_H
#define STUDENT_H

您是否从另一个也包含在内的 .h 文件中得到它?

于 2012-09-30T04:41:46.260 回答