Page 1 of 1

"tty.h" explanation?

Posted: Sat Aug 11, 2018 7:48 am
by RAYG11
Hello
I was having a look at the "Meaty Skeleton" after building a basic cli style OS from the "Bare Bones" source.
I understand almost all of it now apart from "tty.h":

Code: Select all

#ifndef _KERNEL_TTY_H
#define _KERNEL_TTY_H
 
#include <stddef.h>
 
void terminal_initialize(void);
void terminal_putchar(char c);
void terminal_write(const char* data, size_t size);
void terminal_writestring(const char* data);
 
#endif
Where is the source for the four functions defined in "tty.h" located and what does the second line, #define _KERNEL_TTY_H, do?
Thank you in advance :)

Re: "tty.h" explanation?

Posted: Sat Aug 11, 2018 9:04 am
by iansjack
The functions are defined in tty.c.

That line is there to prevent the include file from being included more than once.

Re: "tty.h" explanation?

Posted: Sat Aug 11, 2018 9:10 am
by RAYG11
iansjack wrote:The functions are defined in tty.c.

That line is there to prevent the include file from being included more than once.
hello
thank you for the response. any idea where i can find "tty.c"? also do you know what effect "#define _KERNEL_TTY_H" is having?
cheers

Re: "tty.h" explanation?

Posted: Sat Aug 11, 2018 9:44 am
by iansjack
If you look at the list of source files you will see "kernel/arch/i386/tty.c".

The #define line is used in conjunction with the #ifndef line. It's a very common construct in C header files. You should perhaps brush up on your knowledge of C and how include files are used before proceeding.

Re: "tty.h" explanation?

Posted: Sat Aug 11, 2018 10:03 am
by RAYG11
iansjack wrote:If you look at the list of source files you will see "kernel/arch/i386/tty.c".

The #define line is used in conjunction with the #ifndef line. It's a very common construct in C header files. You should perhaps brush up on your knowledge of C and how include files are used before proceeding.
i guess so.
thanks anyway :)