首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 操作系统 > UNIXLINUX >

extern 的疑问:解决办法

2012-02-06 
extern 的疑问:simple.c:intmyextern(inta){intbba*3returnb}hello.c:#includestdio.hexternintmyex

extern 的疑问:
simple.c   :

int   myextern(int   a)
{
  int   b;
  b=a*3;
  return   b;
}


hello.c   :

#include   <stdio.h>
extern   int   myextern(int   a);
int   main(){
      int   input=10;
      int   output;
      output=myextern(input);
      return   output;
}

这两个文件都位于/root下,用gcc   -o   hello   hello.c出错.请问该怎么用?

[解决办法]
gcc -o hello hello.c sample.c
[解决办法]
你编译不加上sample.c怎么能找到extern的函数?
gcc -o hello sample.c hello.c

热点排行