Page 1 of 1

Multible definitions.

Posted: Thu Oct 19, 2006 12:57 pm
by morphycs
I have declared the video memory pointer and cursor(x, y) in the file 'console.h', this file is used in two C files by assigning new values for cursor as its position will be updated while typing,
But when I compile the kernel it gives this error:
console.o: (.data+0x0): multiple definition of `textmemptr'
kernel.o: (.data+0x0): first defined here
console.o: (.data+0x4): multiple definition of `attrib'
kernel.o: (.data+0x4): first defined here
console.o: (.bss+0x0): multiple definition of `csr_x'
kernel.o: (.bss+0x0): first defined here
console.o: (.bss+0x4): multiple definition of `csr_y'
kernel.o: (.bss+0x4): first defined here
stdio.o: (.data+0x0): multiple definition of `textmemptr'
kernel.o: (.data+0x0): first defined here
stdio.o: (.data+0x4): multiple definition of `attrib'
kernel.o: (.data+0x4): first defined here
stdio.o: (.bss+0x0): multiple definition of `csr_x'
kernel.o: (.bss+0x0): first defined here
stdio.o: (.bss+0x4): multiple definition of `csr_y'
kernel.o: (.bss+0x4): first defined here

Posted: Thu Oct 19, 2006 1:01 pm
by theubu
I'm just taking a stab at this but I'm assuming in your header file you didn't define the variable with extern... so when you include that header file the vairable is allocated in each file... I would do something like

char *videoBuffer = (char *)0xB80000; in your console then in the header
extern char *videoBuffer;


-Christopher

Warnings

Posted: Thu Oct 19, 2006 1:13 pm
by morphycs
'extern' did the job very well, thanks.
I'm getting too many warnings when calling functions:

./kernel/libc/stdio.c: In function ‘puts’:
./kernel/libc/stdio.c:118: warning: pointer targets in passing argument 1 of ‘st rlen’ differ in signedness
./kernel/dev/keyboard.c: In function ‘keyboard_handler’:
./kernel/dev/keyboard.c:94: warning: pointer targets in passing argument 1 of ‘p uts’ differ in signedness
./kernel/timer.c: In function ‘timer_handler’:
./kernel/timer.c:22: warning: pointer targets in passing argument 1 of ‘puts’ di ffer in signedness
./kernel/isrs.c:95: warning: pointer targets in initialization differ in signedn ess
./kernel/isrs.c:96: warning: pointer targets in initialization differ in signedn ess
./kernel/isrs.c:97: warning: pointer targets in initialization differ in signedn ess
./kernel/isrs.c:98: warning: pointer targets in initialization differ in signedn ess
./kernel/isrs.c:99: warning: pointer targets in initialization differ in signedn ess
./kernel/isrs.c:100: warning: pointer targets in initialization differ in signed ness
./kernel/isrs.c:101: warning: pointer targets in initialization differ in signed ness
./kernel/isrs.c:102: warning: pointer targets in initialization differ in signed ness
./kernel/isrs.c:104: warning: pointer targets in initialization differ in signed ness
./kernel/isrs.c:105: warning: pointer targets in initialization differ in signed ness
./kernel/isrs.c:106: warning: pointer targets in initialization differ in signed ness
./kernel/isrs.c:107: warning: pointer targets in initialization differ in signed ness
./kernel/isrs.c:108: warning: pointer targets in initialization differ in signed ness
./kernel/isrs.c:109: warning: pointer targets in initialization differ in signed ness
./kernel/isrs.c:110: warning: pointer targets in initialization differ in signed ness
./kernel/isrs.c:111: warning: pointer targets in initialization differ in signed ness
./kernel/isrs.c:113: warning: pointer targets in initialization differ in signed ness
./kernel/isrs.c:114: warning: pointer targets in initialization differ in signed ness
./kernel/isrs.c:115: warning: pointer targets in initialization differ in signed ness
./kernel/isrs.c:116: warning: pointer targets in initialization differ in signed ness
./kernel/isrs.c:117: warning: pointer targets in initialization differ in signed ness
./kernel/isrs.c:118: warning: pointer targets in initialization differ in signed ness
./kernel/isrs.c:119: warning: pointer targets in initialization differ in signed ness
./kernel/isrs.c:120: warning: pointer targets in initialization differ in signed ness
./kernel/isrs.c:122: warning: pointer targets in initialization differ in signed ness
./kernel/isrs.c:123: warning: pointer targets in initialization differ in signed ness
./kernel/isrs.c:124: warning: pointer targets in initialization differ in signed ness
./kernel/isrs.c:125: warning: pointer targets in initialization differ in signed ness
./kernel/isrs.c:126: warning: pointer targets in initialization differ in signed ness
./kernel/isrs.c:127: warning: pointer targets in initialization differ in signed ness
./kernel/isrs.c:128: warning: pointer targets in initialization differ in signed ness
./kernel/isrs.c:130: warning: pointer targets in initialization differ in signed ness
./kernel/isrs.c: In function ‘fault_handler’:
./kernel/isrs.c:142: warning: pointer targets in passing argument 1 of ‘puts’ di ffer in signedness
./kernel/isrs.c:144: warning: pointer targets in passing argument 1 of ‘puts’ di ffer in signedness
./kernel/idt.c: In function ‘idt_install’:
./kernel/idt.c:63: warning: assignment makes integer from pointer without a cast
./kernel/gdt.c: In function ‘gdt_install’:
./kernel/gdt.c:69: warning: assignment makes integer from pointer without a cast
./kernel/kernel.c: In function ‘setup’:
./kernel/kernel.c:33: warning: pointer targets in passing argument 1 of ‘puts’ d iffer in signedness
./kernel/kernel.c:36: warning: pointer targets in passing argument 1 of ‘puts’ d iffer in signedness
./kernel/kernel.c:39: warning: pointer targets in passing argument 1 of ‘puts’ d iffer in signedness
./kernel/kernel.c:42: warning: pointer targets in passing argument 1 of ‘puts’ d iffer in signedness
./kernel/kernel.c:45: warning: pointer targets in passing argument 1 of ‘puts’ d iffer in signedness
./kernel/kernel.c:48: warning: pointer targets in passing argument 1 of ‘puts’ d iffer in signedness
./kernel/kernel.c:51: warning: pointer targets in passing argument 1 of ‘puts’ d iffer in signedness
./kernel/kernel.c:54: warning: pointer targets in passing argument 1 of ‘puts’ d iffer in signedness
./kernel/kernel.c:57: warning: pointer targets in passing argument 1 of ‘puts’ d iffer in signedness
./kernel/kernel.c:61: warning: pointer targets in passing argument 1 of ‘puts’ d iffer in signedness
./kernel/kernel.c:63: warning: pointer targets in passing argument 1 of ‘puts’ d iffer in signedness
./kernel/kernel.c: In function ‘main’:
./kernel/kernel.c:77: warning: pointer targets in passing argument 1 of ‘puts’ d iffer in signedness
./kernel/kernel.c:80: warning: pointer targets in passing argument 1 of ‘puts’ d iffer in signedness

Posted: Thu Oct 19, 2006 1:19 pm
by theubu
Well I'm not going to clear up all of your errors how ever you should check into your casting make sure when you're using your variables they are all of the same type

example:

void exampleFunction() {
uInt32 *entryAddr = 0x0;
int defaultAddr = 0x800400000;



entryAddr = (uInt32)defaultAddr;

}

Posted: Thu Oct 19, 2006 2:11 pm
by morphycs
Yes, I understand casting but when I call function like puts("something\n");
It gives this warning:
'pointer targets in passing argument 1 of ‘puts’ differ in signedness'

void puts(unsigned char * text);

So, each time I want to print string I have to do this:
unsigned char *buff[50] = "something\n";
puts(buff);

Posted: Thu Oct 19, 2006 2:14 pm
by theubu
or puts((unsigned char *)"something\n");

but what are you unsigning char on your puts?

Posted: Thu Oct 19, 2006 6:46 pm
by Midas
Style note: You shouldn't deviate from the standard when you're naming a function after one in the standard. In this case, the prototype for puts is puts(const char*).

Note the use of a signed char, as ASCII only uses 7 bits. There are 'extended ASCII' things out there, which aren't true ASCII - they take advantage of the 'spare' bit to add in other characters - but this depends largely on the codepage being used so you want to avoid that where possible. Also, that 'spare' bit is handy - for parity bits, say.

The problem arises with string literals being taken as signed char arrays, but your function is expecting an unsigned char.

learn C!

Posted: Sat Oct 21, 2006 9:00 pm
by proxy
really the big issue is that you need to learn the C language better before tackeling any large projects. It is not my intention to mean or discourage you, but you really need to know how to use the language before you start a project as large as an OS.

proxy

Posted: Sat Oct 21, 2006 9:16 pm
by rexlunae
You should make sure that both the include files and libraries that are getting used are the ones for your OS, not the standard ones for the host OS. If you are, for instance using your include files and the system's library, since you are using a non-standard prototype for puts, you could get warnings like the ones listed.

I agree with what Midas said about deviating from standards. However, first you need to make sure you are using the correct libraries and header files, because that's a problem that would come back to haunt you later if you don't fix it.