Having Compilation Issues with GCC

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.
Post Reply
sparticvs
Posts: 2
Joined: Sun Feb 08, 2009 3:16 pm

Having Compilation Issues with GCC

Post by sparticvs »

I am following JamesM's tutorial on rolling your own kernel, and when I am compiling the kernel (just a basic one), I get the following errors:

main.cpp:8: error: first argument of ‘int main(multiboot*)’ should be ‘int’
main.cpp:8: error: ‘int main(multiboot*)’ takes only zero or two arguments
main.cpp: In function ‘int main(multiboot*)’:
main.cpp:13: warning: deprecated conversion from string constant to ‘char*’
main.cpp:15: warning: deprecated conversion from string constant to ‘char*’
main.cpp:17: warning: deprecated conversion from string constant to ‘char*’
main.cpp:20: warning: deprecated conversion from string constant to ‘char*’
main.cpp:24: warning: deprecated conversion from string constant to ‘char*’
main.cpp:28: warning: deprecated conversion from string constant to ‘char*’


I am using gcc version 4.3.2 (Ubuntu 4.3.2-1ubuntu12). Anyone have any ideas?
User avatar
AndrewAPrice
Member
Member
Posts: 2306
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Re: Having Compilation Issues with GCC

Post by AndrewAPrice »

What compile switches are you using? Also try kmain instead of main if all else fails.
My OS is Perception.
ru2aqare
Member
Member
Posts: 342
Joined: Fri Jul 11, 2008 5:15 am
Location: Hungary

Re: Having Compilation Issues with GCC

Post by ru2aqare »

sparticvs wrote:main.cpp:13: warning: deprecated conversion from string constant to ‘char*’
main.cpp:15: warning: deprecated conversion from string constant to ‘char*’
main.cpp:17: warning: deprecated conversion from string constant to ‘char*’
main.cpp:20: warning: deprecated conversion from string constant to ‘char*’
main.cpp:24: warning: deprecated conversion from string constant to ‘char*’
main.cpp:28: warning: deprecated conversion from string constant to ‘char*’
Try replacing char* with const char*, to signal the compiler that you don't intend to write to the string constants. As for the errors, I don't have any ideas.
eddyb
Member
Member
Posts: 248
Joined: Fri Aug 01, 2008 7:52 am

Re: Having Compilation Issues with GCC

Post by eddyb »

complete reply:
for the error: gcc expects a main of form in main(int argc, char **argv). so, replace main with kmain everywhere.
for thee warnings: use constant char* instead of char* when it's about a string(things like puts, printf, etc).
sparticvs
Posts: 2
Joined: Sun Feb 08, 2009 3:16 pm

Re: Having Compilation Issues with GCC

Post by sparticvs »

Wonderful idea, thanks...honestly don't know why I didn't think of that..
Post Reply