日期:2014-05-16  浏览次数:20603 次

请大家帮忙看下这个编译错误!
文件t1.c:

#include <stdio.h>
static char *title = NULL;

void set_title(char *s)
{
  title = s;
}

int main(void)
{
  printf(title);
  return 0;
}

文件t2.c:
extern void set_title(char *s);
set_title("test");

命令:
gcc -Wall -c t1.c
ar rv libt.a t1.o
gcc -Wall -L. -lt t2.c -o t2
这一步时就出现:
t2.c:2:14: error: expected declaration specifiers or '...' before string constant
这是什么出错了!! 谢谢了.

------解决方案--------------------
t2.c 里面这个函数出错了?

C/C++ code


set_title("test");