Hello everybody,
I am Matthijs, I'm 14 years old and I live in Holland.
Right now I'm busy programming my own hobby operating system.
I have made a basic bootloader and kernel (Printing onscreen, GDT, IDT, ISRs, IRQs, System clock, Keyboard and mouse support).
I was wondering if there's any possibility to write your own stdio.h sort of file?
Greetings,
Matthijs
writing your own stdio.h sort of file?
-
- Posts: 1
- Joined: Tue Aug 06, 2013 12:13 pm
- Location: The Netherland, Behind my keyboard
writing your own stdio.h sort of file?
Last edited by MatthijsProgrammer on Wed Oct 22, 2014 3:33 am, edited 1 time in total.
Code: Select all
If Me.Energy < 40 Then
Call Coffee()
Else
Call Focus()
End If
- Combuster
- 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: writing your own stdio.h sort of file?
Certainly.
If you want to have a C library for your OS, you will need one anyway. You can use an existing one like PDClib or newlib's, but you can also write your own - the existing ones aren't created by magic either.
Writing the .h file isn't much of an intelligent job either. You will need to get a copy of the C standard, which typically lists exactly what the definitions and types should be like (or in cases where you have freedom, what effect they should have) so you'd end up copying significant bits of the standard itself. Writing the implementations however is a much bigger challenge, and the reason why people use existing code to get past the hassle.
If you want to have a C library for your OS, you will need one anyway. You can use an existing one like PDClib or newlib's, but you can also write your own - the existing ones aren't created by magic either.
Writing the .h file isn't much of an intelligent job either. You will need to get a copy of the C standard, which typically lists exactly what the definitions and types should be like (or in cases where you have freedom, what effect they should have) so you'd end up copying significant bits of the standard itself. Writing the implementations however is a much bigger challenge, and the reason why people use existing code to get past the hassle.
Re: writing your own stdio.h sort of file?
Yes, it's perfectly possible to write your C standard library - I did exactly that for my OS. Writing the header itself is relatively simple, you just look up the applicable standard (C or POSIX or such) and write it. It's slightly more tricky to implement the standard functions in the header (fputc, printf, ...) though. I have written an (unfinished) article on the matter, but it is meant as a follow up to the OS-specific toolchain article: http://wiki.osdev.org/Creating_a_C_Library
It's a lot of work creating your own C library. If you are willing to do it, I recommend making your kernel support program loading and system calls. Then you should set up a OS_Specific_Toolchain (note that I am currently rewriting that article!) and begin construction of your own libc. I am currently documenting this process, stay tuned.
It's a lot of work creating your own C library. If you are willing to do it, I recommend making your kernel support program loading and system calls. Then you should set up a OS_Specific_Toolchain (note that I am currently rewriting that article!) and begin construction of your own libc. I am currently documenting this process, stay tuned.