OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Apr 18, 2024 7:26 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: writing your own stdio.h sort of file?
PostPosted: Thu Aug 08, 2013 4:30 am 
Offline

Joined: Tue Aug 06, 2013 12:13 pm
Posts: 1
Location: The Netherland, Behind my keyboard
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

_________________
Code:
If Me.Energy < 40 Then
Call Coffee()
Else
Call Focus()
End If


Last edited by MatthijsProgrammer on Wed Oct 22, 2014 3:33 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: writing your own stdio.h sort of file?
PostPosted: Thu Aug 08, 2013 4:57 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 3:45 am
Posts: 9301
Location: On the balcony, where I can actually keep 1½m distance
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.

_________________
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]


Top
 Profile  
 
 Post subject: Re: writing your own stdio.h sort of file?
PostPosted: Thu Aug 08, 2013 6:08 am 
Offline
Member
Member
User avatar

Joined: Wed Mar 21, 2012 3:01 pm
Posts: 930
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] and 92 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group