分页: 1 / 1

GCC问题

发表于 : 2011-02-21 21:34
gundamfj
我按照这里的说明学习怎么用GCChttp://wiki.ubuntu.org.cn/index.php?tit ... iant=zh-cn

我按照编译多个源文件那个小节的说明做,最后出现了这个错误,我能够看懂错误提示,但是觉得这个错误很莫名其妙。。。。

错误如下:
root@jack-Aspire-4740:/home/jack/scripts# gcc -Wall hello.c hello_fn.c -o hello
hello.c: In function ‘hello’:
hello.c:3: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
hello.c:6: error: expected ‘{’ at end of input
hello_fn.c: In function ‘hello’:
hello_fn.c:4: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
hello_fn.c:6: error: expected ‘{’ at end of input

代码
hello.c

代码: 全选

#include "hello.h"
int main(void)
{
    hello ("world");
    return 0;
}
hello_fn.c

代码: 全选

#include <stdio.h>
#include "hello.h"
 
void hello (const char * name)
{
    printf ("Hello, %s!\n", name);
}
hello.h

代码: 全选

void hello (const char * name);


不知道怎么改,来求助= =

Re: GCC问题

发表于 : 2011-02-22 11:24
forestchen
看这个编译错误,因该是代码有语法错误.如果可以,你可以贴出来让大家看看.

Re: GCC问题

发表于 : 2011-02-22 22:47
farta
MinGW(gcc在Windows下的移植版本)编译运行没遇到任何问题= =

Re: GCC问题

发表于 : 2011-02-23 18:42
gundamfj
farta 写了:MinGW(gcc在Windows下的移植版本)编译运行没遇到任何问题= =
所以才说这个错误很莫名其妙啊= =

Re: GCC问题

发表于 : 2011-02-23 23:26
racnil
按照LZ写的代码做没有出现编译错误~~

Re: GCC问题

发表于 : 2011-02-24 1:20
BigSnake.NET
把代码粘贴上来,这里的代码没问题,可能你机器上写的那个用了中文标点了

Re: GCC问题

发表于 : 2011-02-24 17:15
racnil
也有可能是在哪个头文件里面或者是哪一行里面多加了一个分号

Re: GCC问题

发表于 : 2011-02-24 17:19
懒蜗牛Gentoo
在hello.h文件的最后加上一个空行看看