Page 2 of 2

Re: Cygwin : error: no 8-bit type

Posted: Sat Jul 17, 2010 7:08 pm
by TheBadBoy
Hi guys!
I've found a book in my school's library teaching the C language , so I've started reading and discovered many new things .To practice , I've took a look at the C bare bones tuto , and wrote a kernel that does 2 things
Clear the screen , Print a hello message in protected mode
it's just to practice . it's loaded by grub .
so i was thinking if someone of you may take a look at my source code and tell me some thins about my programming/writing manner , some advices ....
so the source and the an boot image are included in the attachment .
Thanks guys

Re: Cygwin : error: no 8-bit type

Posted: Sun Jul 18, 2010 12:40 am
by Solar
  • In C/C++ it is common practice to start function names with lower case (myFunction()). Only structs and - in C++ - classes are started in uppercase (struct MyStruct, MyClass).
  • Very nice that you documented your functions with source comments!
  • Use a .h file to declare the functions, and a .c file to define them. Place the documentation for each function right before its declaration instead of bundling the docs at the top of the file.
  • Avoid variables that are initialized to some constant value and then only used once. The compiler probably optimizes away the actual creation of the variable on the stack, but it introduces a variable name that's completely irrelevant (msgOEM, udlOEM).
  • Your indenting is good. But you used three-space indent, four-space indent, and tab indent all mixed together. Set your editing environment to using one indenting style consistently. There's some holy war around the subject, but in the end four-space indent and tab-indent are the only two suitable alternatives, and I strongly favor the four-space indent.
  • At various points in the source, you use "magic numbers". (Any numerical constant not -1, 0, or 1.) It's good practice to declare them as int const (or preprocessor token) at one central place, including a quick one-line comment as to what they mean. Especially when those numbers are used in more than one place (e.g. VIDEO_BASE instead of 0xb8000).
  • If your orthography lets something to be desired, don't hesitate to use a spell checker on something like Readme.txt.
I've seen much, much worse C code. You didn't do half bad.

Re: Cygwin : error: no 8-bit type

Posted: Sun Jul 18, 2010 1:38 am
by TheBadBoy
Ok Thanks solar
i'll keep that in mind