LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 833|回复: 5

编译多个源代码文件时,遇到的一个问题

[复制链接]
发表于 2003-8-14 09:57:37 | 显示全部楼层 |阅读模式
我初学linux编程,在编译多个源代码文件时,遇到了一个问题,请各位指教。
源代码如下:
[php]
(1)howdy.c
#include<stdio.h>
#include"helper.h"

int main(void)
{
        printf("Hello, Linux programming world!\n");
        msg();
        return 0;
}

(2)helper.c
#include<stdio.h>

void msg(void)
{
        printf("This message sent from GuoRui.\n");
}
(3)helper.h
void msg(void)
[/php]
命令如下:
gcc howdy.c helper.c -o howdy
错误提示如下:
howdy.c: In function `msg':
howdy.c:5: parse error before '{' token
howdy.c:5: declaration for parameter `main' but no such parameter
howdy.c:7: number of arguments doesn't match prototype
cc1: prototype declaration
发表于 2003-8-14 10:02:52 | 显示全部楼层
(3)helper.h
void msg(void)
should be:
(3)helper.h
void msg(void); //here
 楼主| 发表于 2003-8-14 10:17:00 | 显示全部楼层
why
自由狼-台风 该用户已被删除
发表于 2003-8-14 10:45:27 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
发表于 2003-8-14 17:31:44 | 显示全部楼层
main()函数的声明用int main()就可以了,不要用int main(void)的形式。如果要用命令行参数,可以用int main(int argc, char *argc[])的形式。
以后粘贴代码时要注意缩进,这次我改进了一下,应该好看多了。
 楼主| 发表于 2003-8-14 20:02:15 | 显示全部楼层
谢谢各位
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表