Yes, I have read this article albeva.
And I have implemented my own version of this function.
But why does my kernel calls this function?
how to use C++ with classes
-
- Member
- Posts: 195
- Joined: Tue Aug 26, 2008 11:24 am
- GitHub: https://github.com/sebihepp
-
- Member
- Posts: 195
- Joined: Tue Aug 26, 2008 11:24 am
- GitHub: https://github.com/sebihepp
Re: how to use C++ with classes
Can't anyone help me? I only need to know why my VirtualFunctionHandler is always called although
there is no virtual function. If it helps I can upload my project into a webspace and write down a link here.
Sebihepp
there is no virtual function. If it helps I can upload my project into a webspace and write down a link here.
Sebihepp
Re: how to use C++ with classes
Read the article again then:
Why?
It is a requirement of C++ to provide a backup function to call when a virtual function cannot be called.
-
- Member
- Posts: 195
- Joined: Tue Aug 26, 2008 11:24 am
- GitHub: https://github.com/sebihepp
Re: how to use C++ with classes
Sorry, I must be blind. Or it is because my native language is german.
And just when the instruction "call _main" is executed, this function mentioned above is
called instead.
I use C instead of C++ now, but the source of this error interests me. So if anyone have time to help
me, he is welcome.
Greetings Sebihepp
I always thought, if the compiler cannot call a virtual function, it will report an error?"It is a requirement of C++ to provide a backup function to call when a virtual function cannot be called. "
And just when the instruction "call _main" is executed, this function mentioned above is
called instead.
I use C instead of C++ now, but the source of this error interests me. So if anyone have time to help
me, he is welcome.
Greetings Sebihepp
-
- Member
- Posts: 204
- Joined: Thu Apr 12, 2007 8:15 am
- Location: Michigan
Re: how to use C++ with classes
But sebihepp's question was not just "why", it was "why is my virtual function handler always called??" and just below the text you quoted, the article continues:albeva wrote:Read the article again then:
Why?
It is a requirement of C++ to provide a backup function to call when a virtual function cannot be called.
So either I'm confused, or the actual answer to sebihepp is that he has overwritten the virtual function table of his object... ?If during runtime your kernel detects that a call to a pure virtual function couldn't be made, it calls the above functions. These functions should actually never be called, because without hacks (or through undefined behaviour of your kernel) it is not possible to instantiate a class that doesn't define all pure virtual functions. But nonetheless you have to define these functions or your linker will complain about unresolved symbols.
Some people are offended by the verifiable truth; such people tend to remain blissfully unencumbered by fact.
If you are one of these people, my posts may cause considerable discomfort. Read at your own risk.
If you are one of these people, my posts may cause considerable discomfort. Read at your own risk.
-
- Member
- Posts: 195
- Joined: Tue Aug 26, 2008 11:24 am
- GitHub: https://github.com/sebihepp
Re: how to use C++ with classes
@madeofstaples:
Yes, I am thinking that too. But I have no objects!!!
I have only a main function with a "while (1);" in it.
Sebihepp
Yes, I am thinking that too. But I have no objects!!!
I have only a main function with a "while (1);" in it.
Sebihepp
Re: how to use C++ with classes
see assembly output. It might be some gcc internal stuff. Where it would want to get the address of this function...
- codemastersnake
- Member
- Posts: 148
- Joined: Sun Nov 07, 2004 12:00 am
- Contact:
Re: how to use C++ with classes
Don't discourage anybody!Combuster wrote:In the category required knowledge:
USE A C++ COMPILER AND NOT A C COMPILER.
I seriously doubt you should be developing an OS when you even failed to reach "hello world" level