Programming, for all ages and all languages.
-
Mehmetdev1
- Posts: 23
- Joined: Fri Apr 01, 2022 10:06 am
- Location: Türkiye, Uşak/Merkez
Post
by Mehmetdev1 »
Code: Select all
#include <stdio.h>
void print(char* str)
{
unsigned short* VideoMemory = (unsigned short*)0xb8000;
for(int i = 0; str[i] != '\0'; ++i)
VideoMemory[i] = (VideoMemory[i] & 0xFF00) | str[i];
}
extern "C" void kernelMain(void* multiboot_structure, unsigned int magicnumber)
{
printf("Kapiler İsletim Sistemi");
while(1);
{
}
}
Hello, I am getting an undefined reference error for printf in the Kernel Main process, I will post the codes and the screenshot of the error here.
-
Attachments
-
M. Alp
-
kzinti
- Member
- Posts: 898
- Joined: Mon Feb 02, 2015 7:11 pm
Post
by kzinti »
That's because you didn't implement printf() anywhere, you implemented print().
-
Mehmetdev1
- Posts: 23
- Joined: Fri Apr 01, 2022 10:06 am
- Location: Türkiye, Uşak/Merkez
Post
by Mehmetdev1 »
How can I implement printf?
M. Alp
-
Octocontrabass
- Member
- Posts: 5568
- Joined: Mon Mar 25, 2013 7:01 pm
Post
by Octocontrabass »
Are you sure you want to implement printf? It looks like you want to call print instead of printf.
-
Mehmetdev1
- Posts: 23
- Joined: Fri Apr 01, 2022 10:06 am
- Location: Türkiye, Uşak/Merkez
Post
by Mehmetdev1 »
I want to call printf, not print.
M. Alp
-
Octocontrabass
- Member
- Posts: 5568
- Joined: Mon Mar 25, 2013 7:01 pm
Post
by Octocontrabass »
Why do you want to call printf instead of the print function you've already written?
-
Mehmetdev1
- Posts: 23
- Joined: Fri Apr 01, 2022 10:06 am
- Location: Türkiye, Uşak/Merkez
Post
by Mehmetdev1 »
If I Call the Print Function, It Gives an Error.
M. Alp
-
Mehmetdev1
- Posts: 23
- Joined: Fri Apr 01, 2022 10:06 am
- Location: Türkiye, Uşak/Merkez
Post
by Mehmetdev1 »
Thank goodness I solved the error, the code to solve the error:
Code: Select all
#include <stdio.h>
void print(char* str)
{
unsigned short* VideoMemory = (unsigned short*)0xb8000;
for(int i = 0; str[i] != '\0'; ++i)
VideoMemory[i] = (VideoMemory[i] & 0xFF00) | str[i];
}
extern "C" void kernelMain(void* multiboot_structure, unsigned int magicnumber)
{
print("Kapiler İsletim Sistemi");
while(1);
{
}
}
M. Alp