Posts: 1,272
Threads: 36
Joined: Feb 2003
No no no no no. You guys are misunderstanding him. The BAS file, minus comments, must be <= 64k. The resulting OBJ file must also be <=64k. But when all the OBJs and LIBs are linked to an EXE, the EXE may be as large as real memory allows. Mulitple OBJs may also be combined into a LIB file that is greater than 64k
This is why you guys can produce large EXEs without compiler/linker errors, because the individual modules are small enough. Got it?
So when the compiler or linker start giving you out of memory errors, or file too large errors or whatever, it's time to split the program into multiple modules, each <= 64k.
Posts: 4,307
Threads: 63
Joined: May 2003
Quote:No no no no no. You guys are misunderstanding him. The BAS file, minus comments, must be <= 64k. The resulting OBJ file must also be <=64k. But when all the OBJs and LIBs are linked to an EXE, the EXE may be as large as real memory allows. Mulitple OBJs may also be combined into a LIB file that is greater than 64k
This is why you guys can produce large EXEs without compiler/linker errors, because to individual modules are small enough. Got it?
Yeah, I know. CS= Code Segment. DS = Data segment!
Another thing is the EXE cant be as large as u want it should be <=590Kb(with bare minimum conv. memory occupied by DOS progs i.e. TSRs etc)
Posts: 1,272
Threads: 36
Joined: Feb 2003
Right.
Now to answer Nova's question. It varies, sometimes a file larger than 64k will compile - that takes trial and error, but generally if you want to guarantee that the compiler won't run out of memory, get each module under 64k.
If you've got any DIM SHARED variables, make them COMMON SHARED instead so they will share between modules, then create a new module and move some of the SUBs and FUNCTIONs to it. Don't forget to put all the same DECLAREs, COMMON SHAREDs, TYPEs, etc in the new module, or just put them in an include file and '$INCLUDE it in both modules.
EDIT: You still have to DIMmension shared arrays, but only in the main module.
Posts: 4,307
Threads: 63
Joined: May 2003
Yeah that way u trick the compiler to think ur code is under 64K but in reality ur code may be 640K(using 10 modules of 64k!) 8)
Posts: 1,752
Threads: 21
Joined: Jun 2002
Your code is under 64k as far as the compiler is concerned. Each module is compiled separately and then linked. You're not "tricking" anybody.
Posts: 938
Threads: 104
Joined: Dec 2002
LoL sorry that I haven't responded... At school, you know... and then homework... well, anyway.... so what you are saying is to change my dim shared to common shared? and that will help? it always says 1 severe error: memory overflow. Whenever I consolidate my code it always 'errors' on some different part, so.....
ovaProgramming.
One night I had a dream where I was breaking balls. The next morning,
BALLSBREAKER was born.
Quote: Excellent. Now you can have things without paying for them.
BALLSBREAKER 2
~-_-Status Report-_-~
Engine: 94%
Graphics: 95%
Sound: 100%
A Severe Error has crippled BB2 for the time being... I have to figure it out, but until then you won't see much of it
.
-----------------------------
Posts: 3,343
Threads: 83
Joined: Mar 2003
There's a few tutorials in the WIKI about modulising. One thing you could do is take all your DECLARE, DIM, CONST and TYPE etc statements, put them in a file called "whatever.bi" and $INCLUDE it at the start of each module. But read the WIKI tutorials on it first.
Posts: 4,307
Threads: 63
Joined: May 2003
Quote:LoL sorry that I haven't responded... At school, you know... and then homework... well, anyway.... so what you are saying is to change my dim shared to common shared? and that will help? it always says 1 severe error: memory overflow. Whenever I consolidate my code it always 'errors' on some different part, so.....
I believe that you are supposed to break up your code into modules and then add the COMMON SHARED statements.
See this tut by Na_th_an:
http://faq.qbasicnews.com/?blast=PushingTheLimitsOfQb