C: Difference between revisions

Jump to navigation Jump to search
1,175 bytes removed ,  11 years ago
Nothing worse than a section on learning C by someone who doesn't know it. Replaced it with the appropriate link to the books section.
[unchecked revision][unchecked revision]
m (Interwiki)
(Nothing worse than a section on learning C by someone who doesn't know it. Replaced it with the appropriate link to the books section.)
Line 34:
However, although optimizations increase the severity and apparent number of small bugs in C code, they will never break correct C, assuming the compiler is stable and multi-threading issues are accounted for. Because of this, it is sometimes best to debug with optimizations enabled at all different levels, to make sure that code is absolutely correct. If optimizations are turned off, the bugs are still there, just less noticeable. A release-quality project should work while enabling any combination of optimizations, although it is much harder to make progress while doing so.
 
== LearningSee Calso ==
If you don't know C and plan to use it for osdeving, it might be profitable to begin with some C language exercises.
A good start (you still need to find tutorials, these are just exercises):
* program that writes a string, asks for your name, writes two line breaks and writes another string and the provided name;
* implement strcopy(), strncopy(), strncmp() and other string manipulation functions. What is a buffer overflow?
* implement memmove() or memcpy(). Can you do it with inline assembly so it be faster?
* use inline assembly to perform CPUID and interpret the results;
* use typedefs to name uint32 for a 32-bit unsigned integer type; what type is signed 16-bit?
* use structs and pointers to implement a singly linked lists.
* divide the program with singly linked lists to main.c, list.c and list.h. What is a header guard?
* learn about inline, static, volatile; ternary operator; casts;
* use C preprocessor to write MAX, MIN macros; to print out the current function name, line number;
* use C preprocessor to write a log function which takes a level for the first argument, and uses printf() on the rest of the arguments if the level is higher or equal to current logging threshold.
 
* [http://wiki.osdev.org/Books#C Learning C]
 
== See also ==
* [[C preprocessor]]
* [[C++]]
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.

Navigation menu