gcc编译带自定义头文件问题
helper.h是helper.c的头文件,test.c引用了helper.c的msg方法
- C/C++ code
/*helper.c*/#include <stdio.h>#include <stdlib.h>void msg(void){ printf("hello world.\n");}
- C/C++ code
/*helper.h*/void msg(void)
- C/C++ code
/*test.c*/#include "helper.h"int main(void){ msg(); return 0;}
编译语句如下:
gcc test.c helper.c -o test.out
编译时出错请各位帮忙看看,谢谢
[解决办法]
void msg(void)
不会是没写 ";"吧
[解决办法]
准确做法:
- C/C++ code
#ifndef _HELPER_H_#define _HELPER_H_/*helper.h*/void msg(void);#endif