invalid conversion from 'const char*' to 'char'

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
User avatar
Nekroze
Posts: 18
Joined: Fri Jan 08, 2010 9:37 pm

invalid conversion from 'const char*' to 'char'

Post by Nekroze »

heyo, im compiling my first kernel, i have made a cross compiler with all the latest versions of sources, however...

when i compile i get a LOT of errors that is exactly this
invalid conversion from 'const char*' to 'char'

there are differences between each error to do with the lines and which initialization argument but i know the whole problems stems from this function.

i got this directly from the wiki page Text UI:

Code: Select all

void cli_rawchar(unsigned char c,unsigned char backcol,unsigned char forecol, int x, int y){
	short attrib = (backcol << 4) | (forecol & 0x0f);
	volatile unsigned short *where;
	where = 0xb8000 + (y * 80 + x);
	*where = c | (attrib << 8);
}
from searching i have found that anything that is Constant cannot be converted to non Constant, this is what i have found to be the likely problem however im not sure how to fix it or how it works different in OSdev programming.

Thanks in advance guys y'all the master guru's,
Nekroze
Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. Albert Einstein
Checkout my website at http://www.eturnilnetwork.com
yorick
Posts: 1
Joined: Sun Jan 31, 2010 6:45 am

Re: invalid conversion from 'const char*' to 'char'

Post by yorick »

It seems like you're trying to call that on a string, like cli_rawchar("hello!", ...), while it only takes one character at the time, so you should do cli_rawchar('h', ...);
User avatar
Nekroze
Posts: 18
Joined: Fri Jan 08, 2010 9:37 pm

Re: invalid conversion from 'const char*' to 'char'

Post by Nekroze »

OMG your too right.

ok my next problem i have.

i managed to get it working to the point where i can boot with qemu into grub from a .img with my kernel in it however when i put kernel 200+8 (that is just the example one from the wiki i did check mine and it is correct)

it comes up with this error:

Code: Select all

Error 13: Invalid or unsupported executable format
i have looked around and i have found in the same wiki page as the example for barebones that to solve this problem i will need to add the AOUT kludge or something may be not perfect with my multi-boot header but im not sure how to fix it, i fitted part of brans kernel development tutorial concerning both fixes and got it to compile and link perfectly but still the same problem.

i just need some more detailed reading material i think just there seems to be nothing on the wiki about the AOUT kludge.

thanks for the fix though yorick mate,
Nekroze
Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. Albert Einstein
Checkout my website at http://www.eturnilnetwork.com
User avatar
Nekroze
Posts: 18
Joined: Fri Jan 08, 2010 9:37 pm

Re: invalid conversion from 'const char*' to 'char'

Post by Nekroze »

oh and back to the screen printing for Text UI, you where right i had a string word at one point but now after attempting to recompile it with that included now a similar error comes up!

the error is close to before but is now:

Code: Select all

note: expected 'unsigned char' but argument is of type 'char *'
there error is still within that function i gave earlier


I think it may be that the function parameters are for unsigned chars but maybe when i call the function like:

Code: Select all

cli_rawchar( "|", "0", "2", 49, i);
i believe it takes "|" and such as Char* rather then what it is meant to.

anyways sorry im so much trouble, thanks,
Nerkoze
Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. Albert Einstein
Checkout my website at http://www.eturnilnetwork.com
neato
Member
Member
Posts: 75
Joined: Fri Jan 15, 2010 2:46 am

Re: invalid conversion from 'const char*' to 'char'

Post by neato »

Try using: '|' instead. You'll never be able to write an OS if you can't tell the difference between a CHAR and CHAR *... just saying you should take some time to study first. Good luck.
User avatar
Nekroze
Posts: 18
Joined: Fri Jan 08, 2010 9:37 pm

Re: invalid conversion from 'const char*' to 'char'

Post by Nekroze »

omg, that wins the stupidest mistake of the day.

sorry. thanks.
Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. Albert Einstein
Checkout my website at http://www.eturnilnetwork.com
User avatar
Nekroze
Posts: 18
Joined: Fri Jan 08, 2010 9:37 pm

Re: invalid conversion from 'const char*' to 'char'

Post by Nekroze »

i am rather new to c/c++ not too new but i still make my noob mistakes.

at the moment i keep having errors with compiling, I've looked around a heap but found nothing on the errors relating to my project in OSdev enough to actually help. can anyone tell me why this errors occur?

i am using this command in cygwin to cross-compile the kernel

Code: Select all

i686-elf-gcc -o kernel.o -c kernel.c -Wall -Wextra -nostdlib -nostartfiles -nodefaultlibs;
and i get this:
Image

I've looked around the net a fair bit, I'm still looking and will continue to until i find something cause this is stopping all my development, just as much as my problem with grub and it saying invalid executable format which is seriously killing my testing abilities and i still cant find anything to fix it.

Nekroze
Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. Albert Einstein
Checkout my website at http://www.eturnilnetwork.com
midir
Member
Member
Posts: 46
Joined: Fri Jun 13, 2008 4:09 pm

Re: invalid conversion from 'const char*' to 'char'

Post by midir »

For problems with the Multiboot format I suggest checking the full spec: http://www.gnu.org/software/grub/manual ... iboot.html
Have you made sure (e.g.,) that the Multiboot header is aligned on a 4-byte boundary?

Generating a map file from LD would probably also explain any strange exe format errors.

Also, some of your warnings:
"multi-character character constant" means you have tried to put multiple characters inside single quotes (used for characters) when you should have used double quotes (used for (pointers to) null-terminated strings of characters)

"assignment makes pointer from integer without cast" -- check your datatypes. Don't assign pointers to ints or assume that they will be the same size (unless they are size_t or addr_t types).
Selenic
Member
Member
Posts: 123
Joined: Sat Jan 23, 2010 2:56 pm

Re: invalid conversion from 'const char*' to 'char'

Post by Selenic »

Nekroze wrote:

Code: Select all

	volatile unsigned short *where;
	where = 0xb8000 + (y * 80 + x);
This is what the 'pointer from integer without a cast' message will about - most warnings are there to tell you that you might have done something wrong (eg, passing 'x' instead of "x" to a char*-accepting function produces this one), but in this case you're right, so it needs a cast.

Also, before you test this code and get weird results, in text modes you have alternating character and attribute bytes. So your offset needs doubling. So the second line I've quoted should be "where = (unsigned short *)(0xb8000 + (y*80 + x)*2)"

Other warnings:
"'struct multiboot_data' declared inside parameter list" - you've put something like this:

Code: Select all

void main(struct multiboot_data { ... } *data)
This is a bad idea usually, because the struct definition is only valid *inside* the function - no other function can create one. It doesn't really matter here, but it'd still be cleaner to put the struct definition separately.

Finally, what I said about warnings being about things which are *usually* wrong: a common example is "if (x = y)"; that's valid, but is usually a typo for "if (x == y)". So you have to tell the compiler that you've taken its warning into account and intended the former behavior, by typing "if ((x = y))"
User avatar
Owen
Member
Member
Posts: 1700
Joined: Fri Jun 13, 2008 3:21 pm
Location: Cambridge, United Kingdom
Contact:

Re: invalid conversion from 'const char*' to 'char'

Post by Owen »

Selenic wrote:Also, before you test this code and get weird results, in text modes you have alternating character and attribute bytes. So your offset needs doubling. So the second line I've quoted should be "where = (unsigned short *)(0xb8000 + (y*80 + x)*2)"
It's a short*. No it shouldn't. Remember: The compiler inserts an implicit "* sizeof(T)" when adding/subtracting integers from pointers of type T*
User avatar
Nekroze
Posts: 18
Joined: Fri Jan 08, 2010 9:37 pm

Re: invalid conversion from 'const char*' to 'char'

Post by Nekroze »

thanks for the assistance once again, sux that the function itself needs changing cause i got that function straight out of the wiki, someone might wanna fix it, i assumed it was right and look where it got me. lol.

Thanks I'ma implement that and get back to y'all
Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. Albert Einstein
Checkout my website at http://www.eturnilnetwork.com
Selenic
Member
Member
Posts: 123
Joined: Sat Jan 23, 2010 2:56 pm

Re: invalid conversion from 'const char*' to 'char'

Post by Selenic »

Owen wrote:
Selenic wrote:Also, before you test this code and get weird results, in text modes you have alternating character and attribute bytes. So your offset needs doubling. So the second line I've quoted should be "where = (unsigned short *)(0xb8000 + (y*80 + x)*2)"
It's a short*. No it shouldn't. Remember: The compiler inserts an implicit "* sizeof(T)" when adding/subtracting integers from pointers of type T*
Actually, we're both right: in the original function, it's interpreted as "((unsigned short *)0xb8000) + (y*80 + x)", while mine has different bracketing - it calculates the address and *then* does the cast; both ways do exactly the same thing.
Nekroze wrote:thanks for the assistance once again, sux that the function itself needs changing cause i got that function straight out of the wiki, someone might wanna fix it, i assumed it was right and look where it got me. lol.
The function looks perfectly fine to me, and most of your errors look like they're to do with how you're calling it. So the problem is your code, not the wiki's...
User avatar
Nekroze
Posts: 18
Joined: Fri Jan 08, 2010 9:37 pm

Re: invalid conversion from 'const char*' to 'char'

Post by Nekroze »

ok on the point of tackling just the multiboot header problems alone.. well no more errors pop up on compile time however grub still calls it an invalid executable format or what ever like i mentioned above.

here i will allow you to download my most successful build so far.
DOWNLOAD

there is a precompiled.img file in the uncompressed folder that i did myself with my cross compiler, all of my current source is there(its rather small) there is also the builder.sh script which works perfectly and goes from source all the way to floppy.img (only tested on cygwin).

i have been using windows qemu with kqemu accelerator, to test the os. after using the builder it says where the kernel is in blocks but if ya wanna use the precompiled one without using the builder at all its the same thing.

kernel 200+8. kernel begins at block 200 and goes for 8 blocks.

PLEASE [-o< if anyone can find out why it still dose not work please tell me I'm loosing my mind. i am doing only the most basics and that dosent even work, and its not my own error prone code its been used before and all.
#-o #-o #-o #-o

Thanks for putting up with me, and helping as much as you all can,
Nerkoze
Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. Albert Einstein
Checkout my website at http://www.eturnilnetwork.com
User avatar
Nekroze
Posts: 18
Joined: Fri Jan 08, 2010 9:37 pm

Re: invalid conversion from 'const char*' to 'char'

Post by Nekroze »

i have just made a small update to my assembly and linker code in another attempt to fix it yet my cygwin is updating atm so i cannot test it. the update is some advice from GRUB Error 13

also there was a tiny error that resulted in a waring when compiling my kernel.c in the above source package. nekrozeOS.zip is the fix of the above version and nekrozeOS - updated.zip is another attempt to fix the bootup.

EDIT: even with the update in the update version it still dose not work for me.

sorry for the inconvenience,
Nekroze
Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. Albert Einstein
Checkout my website at http://www.eturnilnetwork.com
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: invalid conversion from 'const char*' to 'char'

Post by Combuster »

I just ran some basic checks over that zipfile, and your padding size is off. Right now you are telling GRUB to load 4KB of zeroes, which obviously does not contain a multiboot header...
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Locked