Page 1 of 1

Having Compilation Issues with GCC

Posted: Sun Feb 08, 2009 10:59 pm
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?

Re: Having Compilation Issues with GCC

Posted: Sun Feb 08, 2009 11:08 pm
by AndrewAPrice
What compile switches are you using? Also try kmain instead of main if all else fails.

Re: Having Compilation Issues with GCC

Posted: Mon Feb 09, 2009 12:57 am
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.

Re: Having Compilation Issues with GCC

Posted: Mon Feb 09, 2009 1:59 am
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).

Re: Having Compilation Issues with GCC

Posted: Mon Feb 09, 2009 6:59 am
by sparticvs
Wonderful idea, thanks...honestly don't know why I didn't think of that..