首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

gcc编译带自定义头文件有关问题

2012-04-22 
gcc编译带自定义头文件问题helper.h是helper.c的头文件,test.c引用了helper.c的msg方法C/C++ code/*helper

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 

热点排行