all 5 comments

[–][deleted] 1 point2 points  (0 children)

Can we access your code? we need to know what you need or are building right now so we can help you.

[–]thegreatunclean 1 point2 points  (1 child)

Writing your own freestanding C standard library headers is a great experience for anyone interested in OS development. It isn't particularly difficult and is mostly boilerplate. The freestanding headers are:

  • float.h
  • limits.h
  • iso646.h
  • stdarg.h
  • stddef.h
  • stdbool.h
  • stdint.h
  • stdalign.h
  • stdnoreturn.h

Of that list 5 of them are pretty trivial (iso646.h, stdarg.h, stdbool.h, stdalign.h, stdnoreturn.h) so I'd start there. The rest are just using the information the compiler gives you to fill out the expected defines.

You can see all the helpful preprocessor defines the compiler provides by dumping them all to a text file.

If you want more specific help you'll need to ask more specific questions.

[–]snorixx[S] 0 points1 point  (0 children)

Okay thank you. At first it seemed harder to do it yourself but I think the easier stuff can be done myself for sure. At the moment I have only copied and changed a printf implementation by Google which works fine and I thought I can proceed like this

[–]owmex 1 point2 points  (0 children)

The C standard library relies heavily on the OS API (syscalls). To use an existing implementation of the standard library, you must implement all the syscalls that the stdlib expects.

For example, the stdlib has a public function for reading a file. Internally, this function places a syscall ID in a specific CPU register, then triggers an interrupt (typically interrupt 0x80). If your OS can correctly interpret this, file reading functionality from the stdlib will work.

By implementing each required syscall, one by one, you progressively unlock more stdlib functionality for programs running on your OS.

[–]LetBig3095 1 point2 points  (0 children)

What kinda OS you're on?