I've just organized my code by using headers, but just as I've done this, I got a warning that turned into an error when linking.
I have a code(use of a function that is inside a header) in test.c
that is like this:
#include "test1.h"
/* Some code */
main()
{
Testing();
}
And my test1.h
header is like this:
void Testing();
void print(int, int, int, const char*);
And at 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++;
}
}
When I try to compile the code, I got this:
ubuntu@eeepc:~/Development/Test$ gcc -o test.o -c test.c -Wall -Wextra -nostdlib -nostartfiles -nodefaultlibs
test.c: In function ‘main’:
test.c:11: warning: implicit declaration of function ‘Testing’
ubuntu@eeepc:~/Development/Test$
At the time it's just a simple warning, but when I try to link it...
ubuntu@eeepc:~/Development/Test$ ld -T linker.ld -o kernel.bin loader.o test.o
test.o: In functionmain':
Testing'
test.c:(.text+0xfc): undefined reference to
What I need to do?