Code: Select all
kernel.o: In function `prints':
kernel.c:(.text+0x15d): undefined reference to `strlen'
Code: Select all
kernel.o: In function `prints':
kernel.c:(.text+0x15d): undefined reference to `strlen'
NunoLava1998 wrote:I defined it in tty.c. It is valid, it is literally tty.c from meaty skeleton withLukand wrote:If you keep trying to hide your OS that could be written for 5 minutes, for 2 mins if you copy paste meaty skeleton as you did, there's few things I could suspect:
- You did not included apporiate header with prints() definition.
- You did not declared prints() in any header at all.
However, GCC compiled fine with -w. I use -w beacuse some errors in my code are intended and if they aren't GCC will just fix it anyway
terminal_writestring:prints:Code: Select all
void terminal_writestring(const char* data) { terminal_write(data, strlen(data)); }
Code: Select all
void prints(const char* data) { terminal_write(data, strlen(data)); }
How do i declare? Does aLukand wrote:NunoLava1998 wrote:I defined it in tty.c. It is valid, it is literally tty.c from meaty skeleton withLukand wrote:If you keep trying to hide your OS that could be written for 5 minutes, for 2 mins if you copy paste meaty skeleton as you did, there's few things I could suspect:
- You did not included apporiate header with prints() definition.
- You did not declared prints() in any header at all.
However, GCC compiled fine with -w. I use -w beacuse some errors in my code are intended and if they aren't GCC will just fix it anyway
terminal_writestring:prints:Code: Select all
void terminal_writestring(const char* data) { terminal_write(data, strlen(data)); }
Code: Select all
void prints(const char* data) { terminal_write(data, strlen(data)); }
Repeating:
You may defined your function, but did not declared it in any header (.h) .
- You did not included apporiate header with prints() definition.
- You did not declared prints() in any header at all.
Code: Select all
return;
Code: Select all
In file included from i:\ghost-i686-elf-tools\lib\gcc\i686-elf\4.8.2\include\strlen.c:23:0,
from include/tty/tty.c:5,
from kernel.c:4:
i:\ghost-i686-elf-tools\lib\gcc\i686-elf\4.8.2\include\stdlib.h: In function '__realpath_chk':
i:\ghost-i686-elf-tools\lib\gcc\i686-elf\4.8.2\include\stdlib.h:22:31: error: unknown type name '__THROW'
size_t __resolvedlen) __THROW __wur;
^
i:\ghost-i686-elf-tools\lib\gcc\i686-elf\4.8.2\include\stdlib.h:24:9: error: expected ')' before '(' token
(const char *__restrict __name,
^
i:\ghost-i686-elf-tools\lib\gcc\i686-elf\4.8.2\include\stdlib.h:27:9: error: expected ')' before '(' token
(const char *__restrict __name,
^
i:\ghost-i686-elf-tools\lib\gcc\i686-elf\4.8.2\include\stdlib.h:33:1: error: unknown type name '__fortify_function'
__fortify_function __wur char *
^
i:\ghost-i686-elf-tools\lib\gcc\i686-elf\4.8.2\include\stdlib.h:33:26: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'char'
__fortify_function __wur char *
^
i:\ghost-i686-elf-tools\lib\gcc\i686-elf\4.8.2\include\stdlib.h:50:24: error: expected '=', ',', ';', 'asm' or '__attribute__' before '__THROW'
size_t __nreal) __THROW __nonnull ((2));
^
i:\ghost-i686-elf-tools\lib\gcc\i686-elf\4.8.2\include\stdlib.h:51:47: error: expected ')' before '(' token
extern int __REDIRECT_NTH (__ptsname_r_alias, (int __fd, char *__buf,
^
i:\ghost-i686-elf-tools\lib\gcc\i686-elf\4.8.2\include\stdlib.h:55:7: error: expected ')' before '(' token
(int __fd, char *__buf, size_t __buflen,
^
i:\ghost-i686-elf-tools\lib\gcc\i686-elf\4.8.2\include\stdlib.h:60:1: error: expected declaration specifiers before '__fortify_function'
__fortify_function int
^
i:\ghost-i686-elf-tools\lib\gcc\i686-elf\4.8.2\include\stdlib.h:75:3: error: expected '=', ',', ';', 'asm' or '__attribute__' before '__THROW'
__THROW __wur;
^
i:\ghost-i686-elf-tools\lib\gcc\i686-elf\4.8.2\include\stdlib.h:76:44: error: expected ')' before '(' token
extern int __REDIRECT_NTH (__wctomb_alias, (char *__s, wchar_t __wchar),
^
i:\ghost-i686-elf-tools\lib\gcc\i686-elf\4.8.2\include\stdlib.h:79:1: error: unknown type name '__fortify_function'
__fortify_function __wur int
^
i:\ghost-i686-elf-tools\lib\gcc\i686-elf\4.8.2\include\stdlib.h:79:26: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'int'
__fortify_function __wur int
^
i:\ghost-i686-elf-tools\lib\gcc\i686-elf\4.8.2\include\stdlib.h:97:41: error: expected '=', ',', ';', 'asm' or '__attribute__' before '__THROW'
size_t __len, size_t __dstlen) __THROW;
^
i:\ghost-i686-elf-tools\lib\gcc\i686-elf\4.8.2\include\stdlib.h:99:10: error: expected ')' before '(' token
(wchar_t *__restrict __dst,
^
i:\ghost-i686-elf-tools\lib\gcc\i686-elf\4.8.2\include\stdlib.h:103:10: error: expected ')' before '(' token
(wchar_t *__restrict __dst,
^
i:\ghost-i686-elf-tools\lib\gcc\i686-elf\4.8.2\include\stdlib.h:109:1: error: unknown type name '__fortify_function'
__fortify_function size_t
^
i:\ghost-i686-elf-tools\lib\gcc\i686-elf\4.8.2\include\stdlib.h:110:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '__NTH'
__NTH (mbstowcs (wchar_t *__restrict __dst, const char *__restrict __src,
^
i:\ghost-i686-elf-tools\lib\gcc\i686-elf\4.8.2\include\stdlib.h:129:41: error: expected '=', ',', ';', 'asm' or '__attribute__' before '__THROW'
size_t __len, size_t __dstlen) __THROW;
^
i:\ghost-i686-elf-tools\lib\gcc\i686-elf\4.8.2\include\stdlib.h:131:10: error: expected ')' before '(' token
(char *__restrict __dst,
^
i:\ghost-i686-elf-tools\lib\gcc\i686-elf\4.8.2\include\stdlib.h:135:10: error: expected ')' before '(' token
(char *__restrict __dst,
^
i:\ghost-i686-elf-tools\lib\gcc\i686-elf\4.8.2\include\stdlib.h:140:1: error: unknown type name '__fortify_function'
__fortify_function size_t
^
i:\ghost-i686-elf-tools\lib\gcc\i686-elf\4.8.2\include\stdlib.h:141:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '__NTH'
__NTH (wcstombs (char *__restrict __dst, const wchar_t *__restrict __src,
^
In file included from include/tty/tty.c:5:0,
from kernel.c:4:
i:\ghost-i686-elf-tools\lib\gcc\i686-elf\4.8.2\include\strlen.c:29:7: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'const'
const char *str;
^
In file included from i:\ghost-i686-elf-tools\lib\gcc\i686-elf\4.8.2\include\strlen.c:23:0,
from include/tty/tty.c:5,
from kernel.c:4:
i:\ghost-i686-elf-tools\lib\gcc\i686-elf\4.8.2\include\stdlib.h:20:14: error: old-style parameter declarations in prototyped function definition
extern char *__realpath_chk (const char *__restrict __name,
^
In file included from include/tty/tty.c:5:0,
from kernel.c:4:
i:\ghost-i686-elf-tools\lib\gcc\i686-elf\4.8.2\include\strlen.c:34:20: error: 'str' undeclared (first use in this function)
for (char_ptr = str; ((unsigned long int) char_ptr
^
i:\ghost-i686-elf-tools\lib\gcc\i686-elf\4.8.2\include\strlen.c:34:20: note: each undeclared identifier is reported only once for each function it appears in
In file included from kernel.c:4:0:
include/tty/tty.c: In function 'libc_hidden_builtin_def':
include/tty/tty.c:7:21: error: storage class specified for parameter 'VGA_WIDTH'
static const size_t VGA_WIDTH = 80;
^
include/tty/tty.c:7:1: error: parameter 'VGA_WIDTH' is initialized
static const size_t VGA_WIDTH = 80;
^
include/tty/tty.c:8:21: error: storage class specified for parameter 'VGA_HEIGHT'
static const size_t VGA_HEIGHT = 25;
^
include/tty/tty.c:8:1: error: parameter 'VGA_HEIGHT' is initialized
static const size_t VGA_HEIGHT = 25;
^
include/tty/tty.c:9:24: error: storage class specified for parameter 'VGA_MEMORY'
static uint16_t* const VGA_MEMORY = (uint16_t*) 0xB8000;
^
include/tty/tty.c:9:1: error: parameter 'VGA_MEMORY' is initialized
static uint16_t* const VGA_MEMORY = (uint16_t*) 0xB8000;
^
include/tty/tty.c:11:15: error: storage class specified for parameter 'terminal_row'
static size_t terminal_row;
^
include/tty/tty.c:12:15: error: storage class specified for parameter 'terminal_column'
static size_t terminal_column;
^
include/tty/tty.c:13:16: error: storage class specified for parameter 'terminal_color'
static uint8_t terminal_color;
^
include/tty/tty.c:14:18: error: storage class specified for parameter 'terminal_buffer'
static uint16_t* terminal_buffer;
^
include/tty/tty.c:16:32: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
void terminal_initialize(void) {
^
include/tty/tty.c:29:39: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
void terminal_setcolor(uint8_t color) {
^
include/tty/tty.c:33:78: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
void terminal_putentryat(unsigned char c, uint8_t color, size_t x, size_t y) {
^
include/tty/tty.c:38:31: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
void terminal_putchar(char c) {
^
include/tty/tty.c:48:52: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
void terminal_write(const char* data, size_t size) {
^
include/tty/tty.c:53:31: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
void prints(const char* data) {
^
In file included from kernel.c:5:0:
include/kbd/kbd.c:9:1: error: parameter 'kbdus' is initialized
unsigned char kbdus[128] =
^
include/kbd/kbd.c:49:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
{
^
include/kbd/kbd.c:57:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
{
^
include/kbd/kbd.c:65:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
{
^
include/kbd/kbd.c:69:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
{
^
kernel.c:7:24: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
void kernel_main(void) {
^
kernel.c:16:23: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
void newlinef123(void){
^
In file included from kernel.c:5:0:
include/kbd/kbd.c:9:15: error: declaration for parameter 'kbdus' but no such parameter
unsigned char kbdus[128] =
^
include/kbd/kbd.c:7:5: error: declaration for parameter 'Key' but no such parameter
int Key;
^
include/kbd/kbd.c:6:5: error: declaration for parameter 'ScanCode' but no such parameter
int ScanCode;
^
In file included from kernel.c:4:0:
include/tty/tty.c:14:18: error: declaration for parameter 'terminal_buffer' but no such parameter
static uint16_t* terminal_buffer;
^
include/tty/tty.c:13:16: error: declaration for parameter 'terminal_color' but no such parameter
static uint8_t terminal_color;
^
include/tty/tty.c:12:15: error: declaration for parameter 'terminal_column' but no such parameter
static size_t terminal_column;
^
include/tty/tty.c:11:15: error: declaration for parameter 'terminal_row' but no such parameter
static size_t terminal_row;
^
include/tty/tty.c:9:24: error: declaration for parameter 'VGA_MEMORY' but no such parameter
static uint16_t* const VGA_MEMORY = (uint16_t*) 0xB8000;
^
include/tty/tty.c:8:21: error: declaration for parameter 'VGA_HEIGHT' but no such parameter
static const size_t VGA_HEIGHT = 25;
^
include/tty/tty.c:7:21: error: declaration for parameter 'VGA_WIDTH' but no such parameter
static const size_t VGA_WIDTH = 80;
^
kernel.c:19:1: error: expected '{' at end of input
}
^
Code: Select all
#include"myheader.h"
#include<cstdio>
int main()
{
printf("%d", add(2,3));
return 0;
}
Code: Select all
#include"myheader.h"
int add(int a, int b)
{
return a+b;
}
Code: Select all
#pragma once
int add(int a, int b);
Code: Select all
#pragma once
int add(int, int);
Code: Select all
char foo(unsigned int, char[]);
Code: Select all
char foo(unsigned int index, char foo_table[]);
Code: Select all
#include"myheader.h"
int add(int a, int b)
{
return a+b;
}
Code: Select all
int add(int a, int b);
int add(int a, int b)
{
return a+b;
}
He hasn't wasted any of my time. It's actually being wasted by everyone else in this thread.heat wrote:Do we really want to teach basic C/C++ on an OSDev forum? Yeah, I don't think so. I'll just politely tell the OP to actually learn C instead of wasting our time.
My comment was not directed at you, Schol-R-Lea, but at us all (including, quite often, myself).Schol-R-LEA wrote:To be honest, the main reason I haven't done that...
Okay. I was just taking a break since OSDev'ing is (this is not a quote that i made) nor hard, nor easy. It's very hard., which is why i was inactive for a bit of time.Schol-R-LEA wrote:To be honest, the main reason I haven't done that (aside from the fact that I forgot about that feature) is my habitual didacticism - I really do want to help Nuno learn, and my frustration is mainly in the fact that he didn't seem to be listening to our advice. His antics about claiming to be nine, and other things like that, were annoying too, but the really frustrating part was the way he's kept ignoring our recommendations.
NunoLava, if I have said some rash or harsh things to you, I apologize. It was only because I thought you were making serious mistakes, and I hoped to let you know that there were better ways to do things.
Code: Select all
terminal_writestring("");
Or, perhaps, the problem is that your confirmed-to-be-working code isn't confirmed-to-be-working. Just a thought.NunoLava1998 wrote:If a confirmed-to-be-working code fails for no reason, there's gotta be something wrong with my i686-elf-tools.
Meh, time to read a C book.iansjack wrote:Or, perhaps, the problem is that your confirmed-to-be-working code isn't confirmed-to-be-working. Just a thought.NunoLava1998 wrote:If a confirmed-to-be-working code fails for no reason, there's gotta be something wrong with my i686-elf-tools.
"A poor workman blames his tools."
Past time, I would say.NunoLava1998 wrote:Meh, time to read a C book.