读书人

extern 的疑问:解决办法

发布时间: 2012-02-06 15:52:45 作者: rapoo

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

读书人网 >UNIXLINUX

热点推荐