我剛剛通過使用頭來組織我的代碼,但正如我所做的那樣,我得到了一個警告,在鏈接時會變成錯誤。函數的隱式聲明
我有一個代碼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