How do i convert a void* to a unsigned long*?
How do i convert a void* to a unsigned long*?
I am trying to load ISR's. However, i have 32 isr(num) void type functions. Since my function only accepts uint32_t's or unsigned long's, i would like to convert my functions to a uint32_t*, unsigned long* or similar.
(the function is just a void, i point to it in the function).
If i try to do (uintptr_t)isr[num]();, it gives "invalid use of void expression".
If i try (uintptr_t*), same thing.
How would i convert this?
(the function is just a void, i point to it in the function).
If i try to do (uintptr_t)isr[num]();, it gives "invalid use of void expression".
If i try (uintptr_t*), same thing.
How would i convert this?
- hgoel
- Member
- Posts: 89
- Joined: Sun Feb 09, 2014 7:11 pm
- Libera.chat IRC: hgoel
- Location: Within a meter of a computer
Re: How do i convert a void* to a unsigned long*?
By reading up on function pointers and seeing what extra stuff you you have there.
"If the truth is a cruel mistress, than a lie must be a nice girl"
Working on Cardinal
Find me at [url=irc://chat.freenode.net:6697/Cardinal-OS]#Cardinal-OS[/url] on freenode!
Working on Cardinal
Find me at [url=irc://chat.freenode.net:6697/Cardinal-OS]#Cardinal-OS[/url] on freenode!
Re: How do i convert a void* to a unsigned long*?
Keep in mind, this forum is not for teaching beginner-level programming topics.DixiumOS wrote:How would i convert this?
Learn to read.
- dchapiesky
- Member
- Posts: 204
- Joined: Sun Dec 25, 2016 1:54 am
- Libera.chat IRC: dchapiesky
Re: How do i convert a void* to a unsigned long*?
assembly language would be a superior way of accomplishing this task
Plagiarize. Plagiarize. Let not one line escape thine eyes...
Re: How do i convert a void* to a unsigned long*?
Looks like i get invalid void expression every time i try to do or
or any other. I'm gonna try to switch my function type to an unsigned int and convert it to a unsigned long (same size) and see if that works.
Code: Select all
&(uint32_t)isr[num]()
Code: Select all
&(unsigned long)isr[num]()
Re: How do i convert a void* to a unsigned long*?
Finally fixed it.
I had to make my function type an int then in the function do.
I had to make my function type an int then in the function do
Code: Select all
(unsigned)isr[num]()
-
- Member
- Posts: 5513
- Joined: Mon Mar 25, 2013 7:01 pm
Re: How do i convert a void* to a unsigned long*?
No you didn't.DixiumOS wrote:Finally fixed it.
Just like with your terminal_writechar and terminal_writestring (which are both still broken, by the way), your code is obviously wrong.
As suggested in an earlier post, you need to research function pointers.
Re: How do i convert a void* to a unsigned long*?
I didn't even need the pointer, anyway. The tutorial also puts (unsigned), but had the wrong types on the other file, i had to tweak things, i got on a completely different road (when i asked this question), and then went to the correct thing.Octocontrabass wrote:No you didn't.DixiumOS wrote:Finally fixed it.
Just like with your terminal_writechar and terminal_writestring (which are both still broken, by the way), your code is obviously wrong.
As suggested in an earlier post, you need to research function pointers.
Now my only error/warning is a one that i can't seem to understand.
"Just like with your terminal_writechar and terminal_writestring (which are both still broken, by the way)"
I think you looked at the first few posts, and ignored the entire rest
-
- Member
- Posts: 5513
- Joined: Mon Mar 25, 2013 7:01 pm
Re: How do i convert a void* to a unsigned long*?
So if you don't need the pointer, then what exactly are you putting in your IDT? (And where is your assembly wrapper for your ISRs? You can't do IRET in inline assembly.)DixiumOS wrote:I didn't even need the pointer, anyway.
This is why we keep telling you to learn C before you start writing an OS.DixiumOS wrote:Now my only error/warning is a one that i can't seem to understand.
No, I'm looking at your repo. Broken code everywhere.DixiumOS wrote:"Just like with your terminal_writechar and terminal_writestring (which are both still broken, by the way)"
I think you looked at the first few posts, and ignored the entire rest
Re: How do i convert a void* to a unsigned long*?
I still haven't updated that.Octocontrabass wrote:No, I'm looking at your repo. Broken code everywhere.DixiumOS wrote:"Just like with your terminal_writechar and terminal_writestring (which are both still broken, by the way)"
I think you looked at the first few posts, and ignored the entire rest
-
- Member
- Posts: 5513
- Joined: Mon Mar 25, 2013 7:01 pm
Re: How do i convert a void* to a unsigned long*?
Now you've updated it, but your code is still broken. You still aren't using function pointers correctly (and even if you were, you still can't use IRET in inline assembly).
- hgoel
- Member
- Posts: 89
- Joined: Sun Feb 09, 2014 7:11 pm
- Libera.chat IRC: hgoel
- Location: Within a meter of a computer
Re: How do i convert a void* to a unsigned long*?
Technically you can, it just needs a lot more care. Agreed on the rest though.Octocontrabass wrote:Now you've updated it, but your code is still broken. You still aren't using function pointers correctly (and even if you were, you still can't use IRET in inline assembly).
"If the truth is a cruel mistress, than a lie must be a nice girl"
Working on Cardinal
Find me at [url=irc://chat.freenode.net:6697/Cardinal-OS]#Cardinal-OS[/url] on freenode!
Working on Cardinal
Find me at [url=irc://chat.freenode.net:6697/Cardinal-OS]#Cardinal-OS[/url] on freenode!