我刚刚通过使用头来组织我的代码,但正如我所做的那样,我得到了一个警告,在链接时会变成错误。函数的隐式声明
我有一个代码test.c
(使用的函数是一个水箱内的)是这样的:
#include "test1.h"
/* Some code */
main()
{
Testing();
}
而且我test1.h
标题是这样的:
void Testing();
void print(int, int, int, const char*);
而在test1.c
void Testing()
{
print(0xF9, 27, 5, "\xC9\\xBB");
}
void print(int colour, int x, int y, const char *string)
{
volatile char *video=(volatile char*)0xB8000 + y*160 + x*2;
while(*string != 0)
{
*video=*string;
string++;
video++;
*video=colour;
video++;
}
}
当我尝试编译代码时,我得到这个:
Ubuntu的@ EeePC的:〜/开发/测试$ gcc的-o test.o -c test.c的-Wall -Wextra -nostdlib -nostartfiles -nodefaultlibs
test.c的:在功能上的主要“:
test.c以11:警告:隐函数声明 '测试'
Ubuntu的@ EeePC的:〜/开发/测试$
在它只是一个简单的警告的时间,但是当我尝试连接它...
Ubuntu的@ EeePC的:〜/开发/测试$ LD-T linker.ld -o kernel.bin loader.o test.o
test.o:在功能main':
测试”
test.c:(.text+0xfc): undefined reference to
我需要做?
什么是“kernel.c”? – 2010-01-27 02:03:24
警告消息中的文件名与您显示的示例命令不匹配。所以,它显然不是你正在运行的代码。我们不知道你在做什么。发布一个我们可以编译的完整示例。另外,在头文件中定义函数是一个坏主意。 – 2010-01-27 02:07:02
对不便,我刚编辑。 – 2010-01-27 02:09:04