[Solved] Globals in FreeBASIC?
[Solved] Globals in FreeBASIC?
Hello,
I have started writing a simple kernel in FreeBASIC. And as the title says I've come to the point where
I can't work without global variables. I know it is nativly possible to use them in C but for some reason
in FreeBASIC it requires the runtime.
So to get to the point: Does anybody know how i can get globals working in FreeBASIC?
greets,
Atlas
I have started writing a simple kernel in FreeBASIC. And as the title says I've come to the point where
I can't work without global variables. I know it is nativly possible to use them in C but for some reason
in FreeBASIC it requires the runtime.
So to get to the point: Does anybody know how i can get globals working in FreeBASIC?
greets,
Atlas
Last edited by Atlas on Sun Aug 19, 2012 2:06 am, edited 1 time in total.
Cogito ergo sum!
-
- Member
- Posts: 510
- Joined: Wed Mar 09, 2011 3:55 am
Re: Globals in FreeBASIC?
I doubt it. BASIC, unlike C, is not really designed for low-level programming, so I doubt many people here have even bothered trying to write an OS with it. You might have better luck asking on a FreeBASIC forum.
Re: Globals in FreeBASIC?
Yes but then I think few to none will no how to write
operating systems. People might know a lot about programming
on top of a "host OS", but I'm quite sure not many would have tried OS-deving yet.
Greets,
Atlas
operating systems. People might know a lot about programming
on top of a "host OS", but I'm quite sure not many would have tried OS-deving yet.
Greets,
Atlas
Cogito ergo sum!
Re: Globals in FreeBASIC?
Hi,
There are pointers and links on the FreeBASIC wiki page and barebones, including a general description of what you need to get the runtime working. I'm guessing that Combuster will come in at some point and be more helpful
Cheers,
Adam
There are pointers and links on the FreeBASIC wiki page and barebones, including a general description of what you need to get the runtime working. I'm guessing that Combuster will come in at some point and be more helpful
Cheers,
Adam
Re: Globals in FreeBASIC?
I've already read and reread those pages quite often.
But im not nearly as far that i can port the complete runtime.
what im trying to do right now is setting up GDT and IDT.
I'm trying to translate this into FreeBASIC.
(I would use C but i don't like the syntax for some reason.
I just always forget semicolons at the end of lines and that sort of thing.)
Greets,
Atlas
But im not nearly as far that i can port the complete runtime.
what im trying to do right now is setting up GDT and IDT.
I'm trying to translate this into FreeBASIC.
(I would use C but i don't like the syntax for some reason.
I just always forget semicolons at the end of lines and that sort of thing.)
Greets,
Atlas
Cogito ergo sum!
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: Globals in FreeBASIC?
That is because globals might just be one of the managed types and FreeBasic drops in a constructor reference to, iirc, fb_hInit which is responsible to set the globals for the runtime before that.I know it is nativly possible to use them in C but for some reason
in FreeBASIC it requires the runtime.
At any rate, you will need a copy of the FreeBasic runtime matching the compiler version. You don't even nearly need all of it, but you should look through it to find the missing functions, then compile them along with your project. In the case of hInit, there's some platform-specific code involved so you have to provide them or you might want to start with a reduced version of that function until you can actually provide all the dependencies.
Bottom line is, you will have to write C code. At least until you're so intimately familiar with the compiler internals that you can perform that functionality in the runtime-free subset of basic.
Re: Globals in FreeBASIC?
Ok I have the FB source but there are about 600 files and i haven't
got the faintest idea which files to look through for those functions.
Greets,
Atlas
got the faintest idea which files to look through for those functions.
Greets,
Atlas
Cogito ergo sum!
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: Globals in FreeBASIC?
Learning to search would be a good start. Explorer can do it, and so can find | xargs grep.
- darkinsanity
- Member
- Posts: 45
- Joined: Wed Sep 17, 2008 3:59 am
- Location: Germany
Re: Globals in FreeBASIC?
Wait, why would you need the runtime for globals? What's wrong with "dim shared" ? If you need the same variable in more than one source file, there is also "common shared".
Also, a look at this might help.
Also, a look at this might help.
Re: Globals in FreeBASIC?
Oh thanks, well at least i don't get blablabla is not declared erreors now.
Why doesn't it work with simple dim?
I'll take a look into Frost, it could help me quite alot.
and I'll also try setting up that runtime sometime.
Greets,
Atlas
Why doesn't it work with simple dim?
I'll take a look into Frost, it could help me quite alot.
and I'll also try setting up that runtime sometime.
Greets,
Atlas
Cogito ergo sum!
- darkinsanity
- Member
- Posts: 45
- Joined: Wed Sep 17, 2008 3:59 am
- Location: Germany
Re: [Solved] Globals in FreeBASIC?
Well, there is no "main" in FreeBASIC, so writing dim outside of a function is the equivalent of declaring a variable inside the main function of C, just like putting any code there is the equivalent to putting it inside main in C.
When you want a global variable in C, you just declare it outside any function, but in FreeBASIC, the compiler would think that you want to use it only outside of functions. So, in FreeBASIC, "dim shared" is necessary to tell the compiler that you need a variable that is not only usable outside of functions (this is the equivalent to "main" in C) but also inside.
I hope it's understandable because I find it a bit hard to explain.
When you want a global variable in C, you just declare it outside any function, but in FreeBASIC, the compiler would think that you want to use it only outside of functions. So, in FreeBASIC, "dim shared" is necessary to tell the compiler that you need a variable that is not only usable outside of functions (this is the equivalent to "main" in C) but also inside.
I hope it's understandable because I find it a bit hard to explain.
Re: [Solved] Globals in FreeBASIC?
Yes it's perfectly understandable.
Greets,
Atlas
Greets,
Atlas
Cogito ergo sum!