Re: Does my keyboard.h work?
Posted: Mon Nov 14, 2016 1:27 pm
Sigh.
The Place to Start for Operating System Developers
https://f.osdev.org/
[*] Mostly the case. warning: things that should belong in sewageoverflow sucks ahead I find solutions for some experienced people which don't really have a "solution" SewageOverflow -.-, so i don't seem to "learn" as SewageOverflow promises.glauxosdever wrote:Hi,
You need to be more self-reliant.
It's ok to ask questions about OS design. Asking, for example, in which ways scheduling could be implemented makes your perspective about scheduling wider and will help you make an informed decision. Moreover, some interesting opinions may be heard, and to experience will be exchanged between OS developers.
On the other hand, asking about errors spit out by the compiler doesn't really seem like an interesting question. People will probably think you don't have the required knowledge, and therefore will not want to help, considering the fact that these errors are easy to fix if you know a bit of C (or if you don't know you can still search about them on the internet). Note however that you shouldn't try to learn a programming language by doing OS development.
Another thing to consider, whether you are ready for OS development. If you can't fix errors, even after you have been told how to fix (most of) them, I fear at least one of these statements are true:Note however that these two issues are most likely interlinked, so it's most probable that both of them apply.
- You have comprehension issues (i.e. can't understand what does the compiler say).
- You are not ready for OS development (i.e. can't fix errors because of lacking knowledge).
So before continuing, ask yourself whether you can deal with the complexity you will meet during OS development. It's not an easy journey, neither a hard one. It's very hard. So be prepared for it.
Regards,
glauxosdever
Thats an odd statement to make. Mind explaining your reasoning here? I agree that this isn't a good use for them (honestly, I would have gone with a few bitwise tests followed by a lookup table over either of those approaches), but in general I would consider enumerations them useful.Lukand wrote:Enums are evil, instead use #define .
Since enums do not support any type except signed integer (except in C++ 2011), you have to cast them to convert them to anything not their type, compiler portability, etc.Schol-R-LEA wrote:Thats an odd statement to make. Mind explaining your reasoning here? I agree that this isn't a good use for them (honestly, I would have gone with a few bitwise tests followed by a lookup table over either of those approaches), but in general I would consider enumerations them useful.Lukand wrote:Enums are evil, instead use #define .
Well... here's the thing. Enumerations aren't really meant to hold values at all, at least not in their original conception; they were for creating ranges of values where the values themselves weren't significant, only the order. The idea was to have an easy way to define a range type that could hold things like days of the week and so forth - something that could be used in an if() or switch() but which would be otherwise valueless. You were never meant to use them for their values at all, just for the ordering they defined.Lukand wrote:Since enums do not support any type except signed integer (except in C++ 2011), you have to cast them to convert them to anything not their type, compiler portability, etc.Schol-R-LEA wrote:Thats an odd statement to make. Mind explaining your reasoning here? I agree that this isn't a good use for them (honestly, I would have gone with a few bitwise tests followed by a lookup table over either of those approaches), but in general I would consider enumerations them useful.Lukand wrote:Enums are evil, instead use #define .
#define's look better and they do not get compiled.
Code: Select all
typedef enum { JAN = 1, MAR = 3, MAY = 5, JUL = 7, AUG, OCT = 10, DEC = 12} Months_With_Thirty_One_Days;
Oh sh*t. Please leave this forum if you don't know C even basically. Your code is full of warnings, it's very long, it now even compiles. You're either a troll or a man who started OS development without basic C knowledge.NunoLava1998 wrote:glauxosdever wrote: Yes.
I first set up a enum for easier reading and to not make this take more time.
I then set up a scan code get (inb/outb IS imported) and a key get which displays the pressed key as long it is in the list.
Here are the full list of errors/warnings/notes:
(the majority are warnings that don't even make sense)Code: Select all
terminalf/fkbd.h:44:2: error: invalid suffix "P_SCD" on integer constant 1P_SCD = 0x02, ^ terminalf/fkbd.h:44:2: error: expected identifier before numeric constant terminalf/fkbd.h:45:2: error: invalid suffix "P_SCD" on integer constant 2P_SCD = 0x03, ^ terminalf/fkbd.h:46:2: error: invalid suffix "P_SCD" on integer constant 3P_SCD = 0x04, ^ terminalf/fkbd.h:47:2: error: invalid suffix "P_SCD" on integer constant 4P_SCD = 0x05, ^ terminalf/fkbd.h:48:2: error: invalid suffix "P_SCD" on integer constant 5P_SCD = 0x06, ^ terminalf/fkbd.h:49:2: error: invalid suffix "P_SCD" on integer constant 6P_SCD = 0x07, ^ terminalf/fkbd.h:50:2: error: invalid suffix "P_SCD" on integer constant 7P_SCD = 0x08, ^ terminalf/fkbd.h:51:2: error: invalid suffix "P_SCD" on integer constant 8P_SCD = 0x09, ^ terminalf/fkbd.h:52:2: error: invalid suffix "P_SCD" on integer constant 9P_SCD = 0x0A, ^ terminalf/fkbd.h:53:2: error: invalid suffix "P_SCD" on integer constant 0P_SCD = 0x0B, ^ terminalf/fkbd.h: In function 'getchar': terminalf/fkbd.h:73:8: error: 'scancode' undeclared (first use in this function) return scancode[getScancode()+1]; ^ terminalf/fkbd.h:73:8: note: each undeclared identifier is reported only once for each function it appears in terminalf/fkbd.h: In function 'getKey': terminalf/fkbd.h:79:6: error: 'scancode' undeclared (first use in this function) if (scancode == AP_SCD) ^ terminalf/fkbd.h:190:16: warning: operation on 'terminal_row' may be undefined [-Wsequence-point] terminal_row = terminal_row++; ^ terminalf/fkbd.h:195:18: error: invalid suffix "P_SCD" on integer constant if (scancode == 1P_SCD) ^ terminalf/fkbd.h:200:18: error: invalid suffix "P_SCD" on integer constant if (scancode == 2P_SCD) ^ terminalf/fkbd.h:205:18: error: invalid suffix "P_SCD" on integer constant if (scancode == 3P_SCD) ^ terminalf/fkbd.h:210:18: error: invalid suffix "P_SCD" on integer constant if (scancode == 4P_SCD) ^ terminalf/fkbd.h:215:18: error: invalid suffix "P_SCD" on integer constant if (scancode == 5P_SCD) ^ terminalf/fkbd.h:220:18: error: invalid suffix "P_SCD" on integer constant if (scancode == 6P_SCD) ^ terminalf/fkbd.h:225:18: error: invalid suffix "P_SCD" on integer constant if (scancode == 7P_SCD) ^ terminalf/fkbd.h:230:18: error: invalid suffix "P_SCD" on integer constant if (scancode == 8P_SCD) ^ terminalf/fkbd.h:235:18: error: invalid suffix "P_SCD" on integer constant if (scancode == 9P_SCD) ^ terminalf/fkbd.h:240:18: error: invalid suffix "P_SCD" on integer constant if (scancode == 0P_SCD) ^ terminalf/fkbd.h:245:18: error: 'SLASHP_SCD' undeclared (first use in this function) if (scancode == SLASHP_SCD) ^ terminalf/fkbd.h:250:18: error: 'POINTP_SCD' undeclared (first use in this function) if (scancode == POINTP_SCD) ^ terminalf/fkbd.h:255:18: error: 'SINGQUOTP_SCD' undeclared (first use in this function) if (scancode == SINGQUOTP_SCD) ^ terminalf/fkbd.h:260:18: error: 'EQUALP_SCD' undeclared (first use in this function) if (scancode == EQUALP_SCD) ^ In file included from terminalf/f.c:7:0, from kernel.c:8: terminalf/printservices.h: At top level: terminalf/printservices.h:20:6: error: nested redefinition of 'enum vga_color' enum vga_color { ^ terminalf/printservices.h:20:6: error: redeclaration of 'enum vga_color' In file included from terminalf/fkbd.h:6:0, from terminalf/f.c:6, from kernel.c:8: terminalf/printservices.h:20:6: note: originally defined here enum vga_color { ^ In file included from terminalf/f.c:7:0, from kernel.c:8: terminalf/printservices.h:21:2: error: redeclaration of enumerator 'VGA_COLOR_BLACK' VGA_COLOR_BLACK = 0, ^ In file included from terminalf/fkbd.h:6:0, from terminalf/f.c:6, from kernel.c:8: terminalf/printservices.h:21:2: note: previous definition of 'VGA_COLOR_BLACK' was here VGA_COLOR_BLACK = 0, ^ In file included from terminalf/f.c:7:0, from kernel.c:8: terminalf/printservices.h:22:2: error: redeclaration of enumerator 'VGA_COLOR_BLUE' VGA_COLOR_BLUE = 1, ^ In file included from terminalf/fkbd.h:6:0, from terminalf/f.c:6, from kernel.c:8: terminalf/printservices.h:22:2: note: previous definition of 'VGA_COLOR_BLUE' was here VGA_COLOR_BLUE = 1, ^ In file included from terminalf/f.c:7:0, from kernel.c:8: terminalf/printservices.h:23:2: error: redeclaration of enumerator 'VGA_COLOR_GREEN' VGA_COLOR_GREEN = 2, ^ In file included from terminalf/fkbd.h:6:0, from terminalf/f.c:6, from kernel.c:8: terminalf/printservices.h:23:2: note: previous definition of 'VGA_COLOR_GREEN' was here VGA_COLOR_GREEN = 2, ^ In file included from terminalf/f.c:7:0, from kernel.c:8: terminalf/printservices.h:24:2: error: redeclaration of enumerator 'VGA_COLOR_CYAN' VGA_COLOR_CYAN = 3, ^ In file included from terminalf/fkbd.h:6:0, from terminalf/f.c:6, from kernel.c:8: terminalf/printservices.h:24:2: note: previous definition of 'VGA_COLOR_CYAN' was here VGA_COLOR_CYAN = 3, ^ In file included from terminalf/f.c:7:0, from kernel.c:8: terminalf/printservices.h:25:2: error: redeclaration of enumerator 'VGA_COLOR_RED' VGA_COLOR_RED = 4, ^ In file included from terminalf/fkbd.h:6:0, from terminalf/f.c:6, from kernel.c:8: terminalf/printservices.h:25:2: note: previous definition of 'VGA_COLOR_RED' was here VGA_COLOR_RED = 4, ^ In file included from terminalf/f.c:7:0, from kernel.c:8: terminalf/printservices.h:26:2: error: redeclaration of enumerator 'VGA_COLOR_MAGENTA' VGA_COLOR_MAGENTA = 5, ^ In file included from terminalf/fkbd.h:6:0, from terminalf/f.c:6, from kernel.c:8: terminalf/printservices.h:26:2: note: previous definition of 'VGA_COLOR_MAGENTA' was here VGA_COLOR_MAGENTA = 5, ^ In file included from terminalf/f.c:7:0, from kernel.c:8: terminalf/printservices.h:27:2: error: redeclaration of enumerator 'VGA_COLOR_BROWN' VGA_COLOR_BROWN = 6, ^ In file included from terminalf/fkbd.h:6:0, from terminalf/f.c:6, from kernel.c:8: terminalf/printservices.h:27:2: note: previous definition of 'VGA_COLOR_BROWN' was here VGA_COLOR_BROWN = 6, ^ In file included from terminalf/f.c:7:0, from kernel.c:8: terminalf/printservices.h:28:2: error: redeclaration of enumerator 'VGA_COLOR_LIGHT_GREY' VGA_COLOR_LIGHT_GREY = 7, ^ In file included from terminalf/fkbd.h:6:0, from terminalf/f.c:6, from kernel.c:8: terminalf/printservices.h:28:2: note: previous definition of 'VGA_COLOR_LIGHT_GREY' was here VGA_COLOR_LIGHT_GREY = 7, ^ In file included from terminalf/f.c:7:0, from kernel.c:8: terminalf/printservices.h:29:2: error: redeclaration of enumerator 'VGA_COLOR_DARK_GREY' VGA_COLOR_DARK_GREY = 8, ^ In file included from terminalf/fkbd.h:6:0, from terminalf/f.c:6, from kernel.c:8: terminalf/printservices.h:29:2: note: previous definition of 'VGA_COLOR_DARK_GREY' was here VGA_COLOR_DARK_GREY = 8, ^ In file included from terminalf/f.c:7:0, from kernel.c:8: terminalf/printservices.h:30:2: error: redeclaration of enumerator 'VGA_COLOR_LIGHT_BLUE' VGA_COLOR_LIGHT_BLUE = 9, ^ In file included from terminalf/fkbd.h:6:0, from terminalf/f.c:6, from kernel.c:8: terminalf/printservices.h:30:2: note: previous definition of 'VGA_COLOR_LIGHT_BLUE' was here VGA_COLOR_LIGHT_BLUE = 9, ^ In file included from terminalf/f.c:7:0, from kernel.c:8: terminalf/printservices.h:31:2: error: redeclaration of enumerator 'VGA_COLOR_LIGHT_GREEN' VGA_COLOR_LIGHT_GREEN = 10, ^ In file included from terminalf/fkbd.h:6:0, from terminalf/f.c:6, from kernel.c:8: terminalf/printservices.h:31:2: note: previous definition of 'VGA_COLOR_LIGHT_GREEN' was here VGA_COLOR_LIGHT_GREEN = 10, ^ In file included from terminalf/f.c:7:0, from kernel.c:8: terminalf/printservices.h:32:2: error: redeclaration of enumerator 'VGA_COLOR_LIGHT_CYAN' VGA_COLOR_LIGHT_CYAN = 11, ^ In file included from terminalf/fkbd.h:6:0, from terminalf/f.c:6, from kernel.c:8: terminalf/printservices.h:32:2: note: previous definition of 'VGA_COLOR_LIGHT_CYAN' was here VGA_COLOR_LIGHT_CYAN = 11, ^ In file included from terminalf/f.c:7:0, from kernel.c:8: terminalf/printservices.h:33:2: error: redeclaration of enumerator 'VGA_COLOR_LIGHT_RED' VGA_COLOR_LIGHT_RED = 12, ^ In file included from terminalf/fkbd.h:6:0, from terminalf/f.c:6, from kernel.c:8: terminalf/printservices.h:33:2: note: previous definition of 'VGA_COLOR_LIGHT_RED' was here VGA_COLOR_LIGHT_RED = 12, ^ In file included from terminalf/f.c:7:0, from kernel.c:8: terminalf/printservices.h:34:2: error: redeclaration of enumerator 'VGA_COLOR_LIGHT_MAGENTA' VGA_COLOR_LIGHT_MAGENTA = 13, ^ In file included from terminalf/fkbd.h:6:0, from terminalf/f.c:6, from kernel.c:8: terminalf/printservices.h:34:2: note: previous definition of 'VGA_COLOR_LIGHT_MAGENTA' was here VGA_COLOR_LIGHT_MAGENTA = 13, ^ In file included from terminalf/f.c:7:0, from kernel.c:8: terminalf/printservices.h:35:2: error: redeclaration of enumerator 'VGA_COLOR_LIGHT_BROWN' VGA_COLOR_LIGHT_BROWN = 14, ^ In file included from terminalf/fkbd.h:6:0, from terminalf/f.c:6, from kernel.c:8: terminalf/printservices.h:35:2: note: previous definition of 'VGA_COLOR_LIGHT_BROWN' was here VGA_COLOR_LIGHT_BROWN = 14, ^ In file included from terminalf/f.c:7:0, from kernel.c:8: terminalf/printservices.h:36:2: error: redeclaration of enumerator 'VGA_COLOR_WHITE' VGA_COLOR_WHITE = 15, ^ In file included from terminalf/fkbd.h:6:0, from terminalf/f.c:6, from kernel.c:8: terminalf/printservices.h:36:2: note: previous definition of 'VGA_COLOR_WHITE' was here VGA_COLOR_WHITE = 15, ^ In file included from terminalf/f.c:7:0, from kernel.c:8: terminalf/printservices.h:39:23: error: redefinition of 'vga_entry_color' static inline uint8_t vga_entry_color(enum vga_color fg, enum vga_color bg) { ^ In file included from terminalf/fkbd.h:6:0, from terminalf/f.c:6, from kernel.c:8: terminalf/printservices.h:39:23: note: previous definition of 'vga_entry_color' was here static inline uint8_t vga_entry_color(enum vga_color fg, enum vga_color bg) { ^ In file included from terminalf/f.c:7:0, from kernel.c:8: terminalf/printservices.h:43:24: error: redefinition of 'vga_entry' static inline uint16_t vga_entry(unsigned char uc, uint8_t color) { ^ In file included from terminalf/fkbd.h:6:0, from terminalf/f.c:6, from kernel.c:8: terminalf/printservices.h:43:24: note: previous definition of 'vga_entry' was here static inline uint16_t vga_entry(unsigned char uc, uint8_t color) { ^ In file included from terminalf/f.c:7:0, from kernel.c:8: terminalf/printservices.h:47:8: error: redefinition of 'strlen' size_t strlen(const char* str) { ^ In file included from terminalf/fkbd.h:6:0, from terminalf/f.c:6, from kernel.c:8: terminalf/printservices.h:47:8: note: previous definition of 'strlen' was here size_t strlen(const char* str) { ^ In file included from terminalf/f.c:7:0, from kernel.c:8: terminalf/printservices.h:54:21: error: redefinition of 'VGA_WIDTH' static const size_t VGA_WIDTH = 80; ^ In file included from terminalf/fkbd.h:6:0, from terminalf/f.c:6, from kernel.c:8: terminalf/printservices.h:54:21: note: previous definition of 'VGA_WIDTH' was here static const size_t VGA_WIDTH = 80; ^ In file included from terminalf/f.c:7:0, from kernel.c:8: terminalf/printservices.h:55:21: error: redefinition of 'VGA_HEIGHT' static const size_t VGA_HEIGHT = 25; ^ In file included from terminalf/fkbd.h:6:0, from terminalf/f.c:6, from kernel.c:8: terminalf/printservices.h:55:21: note: previous definition of 'VGA_HEIGHT' was here static const size_t VGA_HEIGHT = 25; ^ In file included from terminalf/f.c:7:0, from kernel.c:8: terminalf/printservices.h:62:6: error: redefinition of 'terminal_initialize' void terminal_initialize(void) { ^ In file included from terminalf/fkbd.h:6:0, from terminalf/f.c:6, from kernel.c:8: terminalf/printservices.h:62:6: note: previous definition of 'terminal_initialize' was here void terminal_initialize(void) { ^ In file included from terminalf/f.c:7:0, from kernel.c:8: terminalf/printservices.h:75:6: error: redefinition of 'terminal_setcolor' void terminal_setcolor(uint8_t color) { ^ In file included from terminalf/fkbd.h:6:0, from terminalf/f.c:6, from kernel.c:8: terminalf/printservices.h:75:6: note: previous definition of 'terminal_setcolor' was here void terminal_setcolor(uint8_t color) { ^ In file included from terminalf/f.c:7:0, from kernel.c:8: terminalf/printservices.h:79:6: error: redefinition of 'terminal_putentryat' void terminal_putentryat(char c, uint8_t color, size_t x, size_t y) { ^ In file included from terminalf/fkbd.h:6:0, from terminalf/f.c:6, from kernel.c:8: terminalf/printservices.h:79:6: note: previous definition of 'terminal_putentryat' was here void terminal_putentryat(char c, uint8_t color, size_t x, size_t y) { ^ In file included from terminalf/f.c:7:0, from kernel.c:8: terminalf/printservices.h:84:6: error: redefinition of 'terminal_putchar' void terminal_putchar(char c) { ^ In file included from terminalf/fkbd.h:6:0, from terminalf/f.c:6, from kernel.c:8: terminalf/printservices.h:84:6: note: previous definition of 'terminal_putchar' was here void terminal_putchar(char c) { ^ In file included from terminalf/f.c:7:0, from kernel.c:8: terminalf/printservices.h:93:6: error: redefinition of 'terminal_write' void terminal_write(const char* data, size_t size) { ^ In file included from terminalf/fkbd.h:6:0, from terminalf/f.c:6, from kernel.c:8: terminalf/printservices.h:93:6: note: previous definition of 'terminal_write' was here void terminal_write(const char* data, size_t size) { ^ In file included from terminalf/f.c:7:0, from kernel.c:8: terminalf/printservices.h:98:6: error: redefinition of 'terminal_writestring' void terminal_writestring(const char* data) { ^ In file included from terminalf/fkbd.h:6:0, from terminalf/f.c:6, from kernel.c:8: terminalf/printservices.h:98:6: note: previous definition of 'terminal_writestring' was here void terminal_writestring(const char* data) { ^ In file included from terminalf/f.c:6:0, from kernel.c:8: terminalf/fkbd.h: In function 'getchar': terminalf/fkbd.h:74:1: warning: control reaches end of non-void function [-Wreturn-type] } ^ terminalf/fkbd.h: In function 'getKey': terminalf/fkbd.h:265:1: warning: control reaches end of non-void function [-Wreturn-type] } ^
+1iansjack wrote:Just go away and learn C rather than polluting this forum with silly posts.
There's no overhead in handling constants, whether they come from the source code as macro substitutions or enumerations. The compiler sees a constant in both cases and can handle it equally efficiently.Lukand wrote:Since enums do not support any type except signed integer (except in C++ 2011), you have to cast them to convert them to anything not their type, compiler portability, etc.
#define's look better and they do not get compiled.
I agree. Nuno, sorry, but you need to learn that before writing an OS.Lukand wrote:It's because some people do not even know general programming or even little bit algorithmic programming which try to create their OS.
Althrough, considering his age, better idea for him may be to learn more general/algorithmic programming, and then go there.
Come back there when you learn:Wow, you have a looong road...
- Enums
- Pointers
- POSIX functions (So you could explore and learn some algorithms and make your OS little bit POSIX compilant)
- General code optimizations and cyclomatic complexity
- Filling algorithm
- Path finding algorithm
- That Osdev Wiki is not copy-paste tutorial(through, some other bros did not learned it)
- Recursive functions
- To understand sentences
- To understand patents, licenses, legal rights, trademark and (do not read it if you are ever going to live in USA and serve in a jury) law nullification
- Sorting algorithm(For now, let it be simple one)