"tty.h" explanation?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
RAYG11
Posts: 3
Joined: Sat Aug 11, 2018 7:29 am

"tty.h" explanation?

Post 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 :)
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: "tty.h" explanation?

Post by iansjack »

The functions are defined in tty.c.

That line is there to prevent the include file from being included more than once.
RAYG11
Posts: 3
Joined: Sat Aug 11, 2018 7:29 am

Re: "tty.h" explanation?

Post 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
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: "tty.h" explanation?

Post 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.
RAYG11
Posts: 3
Joined: Sat Aug 11, 2018 7:29 am

Re: "tty.h" explanation?

Post 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 :)
Post Reply