Board index » cppbuilder » Error: Too much global data defined in file

Error: Too much global data defined in file


2005-02-19 08:18:44 PM
cppbuilder1
Hello:
I made a C++ program for accountancy purposes, it's DOS style, I compile
using bcc.exe of Borland C++ v5.2. I choose the "large model". Now I have
this new error "Error: Too much global data defined in file" saying that I
have a lot of global variables. I counted the space required for my global
data, it didn't exceed 64k.
my command line is:
bcc -4 -ff -N -ml e:\my_data\prog\tc\%1.cpp>compc.rpt
In the same time, I have a lot of message'strings, but with the large model
there is 1MB of
data space.
Is there any solution for that?
Thanks
Morosh
 
 

Re:Error: Too much global data defined in file

Global and static data go into a combined segment called DGROUP. The
machine hardware limits a segment to 64K.
If you add the keyword 'far' to a global or static data items, the
compiler will flag it to be placed into a different segment and not in
DGROUP. Try locating a few of the largest global data items and
adding that keyword to them.
For example:
char far big_array[2048];
The language standards committee dictated that compiler-specific
keywords begin with an underscore. It has been a while since I did
this with BC++ 5.02 and I don't remember how strictly this is
enforced. If it gives trouble with 'far', then use '_far'.
Please let us know how this works for you.
. Ed
Quote
Morosh wrote in message
news: XXXX@XXXXX.COM ...

I made a C++ program for accountancy purposes, it's DOS style, I
compile using bcc.exe of Borland C++ v5.2. I choose the "large
model". Now I have this new error "Error: Too much global data
defined in file" saying that I have a lot of global variables. I
counted
the space required for my global data, it didn't exceed 64k.
my command line is:

bcc -4 -ff -N -ml e:\my_data\prog\tc\%1.cpp>compc.rpt

In the same time, I have a lot of message'strings, but with the
large
model there is 1MB of data space.

Is there any solution for that?
 

Re:Error: Too much global data defined in file

Hi:
I tried to add "far" or "_far" to the biggest arrays, the result is exactly
the same, (the error is on the same line), my command is : bcc -4 -ff -N -ml
file.cpp
I counted the space required for my global data, it's 13934 bytes only!!!
Curious NO?
Any other idea? (I can send you all my files but do you have time for that?)
thanks
Morosh
Ed Mulroy [TeamB] < XXXX@XXXXX.COM >wrote in message
Quote
Global and static data go into a combined segment called DGROUP. The
machine hardware limits a segment to 64K.

If you add the keyword 'far' to a global or static data items, the
compiler will flag it to be placed into a different segment and not in
DGROUP. Try locating a few of the largest global data items and
adding that keyword to them.

For example:

char far big_array[2048];

The language standards committee dictated that compiler-specific
keywords begin with an underscore. It has been a while since I did
this with BC++ 5.02 and I don't remember how strictly this is
enforced. If it gives trouble with 'far', then use '_far'.

Please let us know how this works for you.

. Ed

>Morosh wrote in message
>news: XXXX@XXXXX.COM ...
>
>I made a C++ program for accountancy purposes, it's DOS style, I
>compile using bcc.exe of Borland C++ v5.2. I choose the "large
>model". Now I have this new error "Error: Too much global data
>defined in file" saying that I have a lot of global variables. I
>counted
>the space required for my global data, it didn't exceed 64k.
>my command line is:

>
>bcc -4 -ff -N -ml e:\my_data\prog\tc\%1.cpp>compc.rpt

>
>In the same time, I have a lot of message'strings, but with the
>large
>model there is 1MB of data space.
>
>Is there any solution for that?


 

{smallsort}

Re:Error: Too much global data defined in file

13394 bytes of global data is not consistent with generating getting
that error.
I do not understand the need for -N since its main value is in small
model programs or the need for -ff because it is on by default.
Yes, please zip it up and send me the project. Please include the
bcc32.cfg file form the compiler's BIN directory. My email address is
ed at mulroy dot org
(translate 'at' to '@' and 'dot' to '.' I used them here as defense
against spammers who automate s{*word*99}ing email addresses from newsgroup
messages)
One warning: I will be out until late tonight (13:53 Sunday here now -
East Coast US) so won't be able to look at this until tommorrow
(Monday) morning.
. Ed
Quote
Morosh wrote in message
news: XXXX@XXXXX.COM ...

I tried to add "far" or "_far" to the biggest arrays, the result is
exactly the same, (the error is on the same line), my command
is : bcc -4 -ff -N -ml file.cpp
I counted the space required for my global data, it's 13934 bytes
only!!!
Curious NO?
Any other idea? (I can send you all my files but do you have time
for that?)
 

Re:Error: Too much global data defined in file

Hello:
I made a C++ program for accountancy purposes, it's DOS style, I compile
using bcc.exe of Borland C++ v5.2. I choose the "large model". Now I have
this new error "Error: Too much global data defined in file" saying that I
have a lot of global variables. I counted the space required for my global
data it's around 14k , it didn't exceed 64k.
my command line is: bcc -4 -ff -N -ml file.cpp
Is there any solution for that?
Thanks
Morosh
 

Re:Error: Too much global data defined in file

You offered to send the source file for analysis and on the 20th I
provided an email address. If you sent it then something went wrong
with the email and a new email is needed.
. Ed
Quote
Morosh wrote in message
news: XXXX@XXXXX.COM ...
Hello:
I made a C++ program for accountancy purposes, it's DOS style, I
compile
using bcc.exe of Borland C++ v5.2. I choose the "large model". Now I
have
this new error "Error: Too much global data defined in file" saying
that I
have a lot of global variables. I counted the space required for my
global
data it's around 14k , it didn't exceed 64k.
my command line is: bcc -4 -ff -N -ml file.cpp
Is there any solution for that?
Thanks
Morosh



 

Re:Error: Too much global data defined in file

Morosh wrote:
Quote
this new error "Error: Too much global data defined in file" saying that I
have a lot of global variables. I counted the space required for my global
data it's around 14k , it didn't exceed 64k.
Did you include all of your string literals in that count?
char Error[64]; 64 bytes of data
strcpy( Error, "Error: Too much global data defined in file");
Another 44 bytes of data.
Total: 108 bytes
 

Re:Error: Too much global data defined in file

Hi:
I've send you twice the project files to the address you specified and had
no reply.
May be they are filtered by a junk filter?
Anyway I'll send them back.
thanks in advance
Morosh
Ed Mulroy [TeamB] < XXXX@XXXXX.COM >wrote in message
Quote
You offered to send the source file for analysis and on the 20th I
provided an email address. If you sent it then something went wrong
with the email and a new email is needed.

. Ed

>Morosh wrote in message
>news: XXXX@XXXXX.COM ...
>Hello:
>I made a C++ program for accountancy purposes, it's DOS style, I
>compile
>using bcc.exe of Borland C++ v5.2. I choose the "large model". Now I
>have
>this new error "Error: Too much global data defined in file" saying
>that I
>have a lot of global variables. I counted the space required for my
>global
>data it's around 14k , it didn't exceed 64k.
>my command line is: bcc -4 -ff -N -ml file.cpp
>Is there any solution for that?
>Thanks
>Morosh
>
>
>


 

Re:Error: Too much global data defined in file

It still has not arrived. I can only guess that it is as you say,
swallowed by a junk mail filter. Send a copy to this address. It
does not have that same filter.
XXXX@XXXXX.COM
. Ed
Quote
Morosh wrote in message
news: XXXX@XXXXX.COM ...


I've send you twice the project files to the address you
specified and had no reply.
May be they are filtered by a junk filter?
Anyway I'll send them back.
 

Re:Error: Too much global data defined in file

"Ed Mulroy [TeamB]" < XXXX@XXXXX.COM >a écrit dans le message de
Quote
It still has not arrived. I can only guess that it is as you say,
swallowed by a junk mail filter. Send a copy to this address. It does
not have that same filter.

May I suggest that you post it on borland.public.attachements
--
Regis St-Gelais
www.laubrass.com
 

Re:Error: Too much global data defined in file

Ed Mulroy [TeamB] < XXXX@XXXXX.COM >wrote in message
Quote
It still has not arrived. I can only guess that it is as you say,
swallowed by a junk mail filter. Send a copy to this address. It
does not have that same filter.

XXXX@XXXXX.COM

. Ed

>Morosh wrote in message
>news: XXXX@XXXXX.COM ...
>
>
>I've send you twice the project files to the address you
>specified and had no reply.
>May be they are filtered by a junk filter?
>Anyway I'll send them back.

done at 13:44 GMT
thanks
 

Re:Error: Too much global data defined in file

The large model forbids more than 64k static data for the entire
application, not just per source file, though that restriction won't be
encountered until you try to link the application.
You have a large number of variables declared in compta.h in such a way
that they are effectively inlined into the compta.cpp file in which
it's included.
Keep in mind that header files are nothing special; the code in them
becomes part of the file in which they are included. The proper way to
manage variables with header files is to declare them in the header
file and define them in a separate source file, thus:
declare.h:
extern char my2DArray[10][20];
define.cpp:
#include "declare.h" // Make sure that declarations match definitions.
char my2DArray[10][20];
Personally, I find your use of such a massive amount of global data to
be somewhat suspect. I don't have time to analyze your code in order
to determine what it's doing and why, but it's generally good practice
to minimize your global data.
--
Kevin Dean [TeamB]
Dolphin Data Development Ltd.
www.datadevelopment.com/
NEW WHITEPAPERS
Team Development with JBuilder and Borland Enterprise Server
Securing Borland Enterprise Server
www.datadevelopment.com/papers/index.html
Please see Borland's newsgroup guidelines at
info.borland.com/newsgroups/guide.html
 

Re:Error: Too much global data defined in file

I have received the email.
I now know why it was discarded by the filters. You used a subject of
"Re:" which duplicates that which is the subject of a lot of spam.
Emails with such subjects are set to be rejected by my filter as I
have no use for ordering illegal {*word*110} and both my wife and I are
content with my current {*word*78} size.
There are many issues with what you sent.
At first glance it appears that the error reporting an excessive
amount of global data may be wrong. It appears that the error more
relates to the massive amount of stack usage for large arrays and
class instances containing large arrays declared as automatic
variables within functions. As the default stack size is 4K, the
program as written guarantees the stack will overflow. You need to
use the help which came with the compiler. In it you will find the
way to alter the stack size of a DOS program is with a single extern
declaration in one source file of this type:
extern unsigned _stklen = 32768U;
where the number assigned must be less than 64K-256 (the operating
system may use as much as 256 extra bytes of the segment) and the U at
the end of the number indicates the number is an unsigned.
That program is quite difficult to analyze because of the way it is
structured.
The bulk of the code is in the header files, both in non-inline class
member function code and in a greater amount of code for standalone,
global functions. Non-inline code should be placed into source files.
Only the function prototypes or associated class definitions should be
in header files.
Storage for all of the global data is declared in the header files.
Declarations allocatiing storage for global data should be placed into
one of the source files and extern declarations for that data placed
into header files.
C++ functions which take no calling parameters use () and not (void)
in their calling argument list.
C++ functions which return int are prototyped and written with a
return type of int and not with no return type. This also applies to
class member functions.
Unlike C, C++ will not convert pointer types. An unsigned int* cannot
be automatically assigned or converted to a char*. The only quiet
automatic conversion for pointer types is to a void*. This call to
complete_ptr specifies a calling argument which is an array name for
unsigned int*.
complete_ptr(ptrtitre[kk][i],' ',*ptrlarg[kk][i]);
Similarly there is an array of errors related to the conversion of a
char near* to unsigned int* starting with this:
ptrflag[0][i]=&flag_s[i]
And a complaint that the type of the parameter 'rslt' is wrong in this
call
get_field_str("comptcfg.fil",dumy1,caisse_cpt[i],EXIT);
I suggest that you start by doing these things:
Copy the global data declarations out of the compta.h header file to a
new source file. Then alter the header file declarations to all have
the keyword 'extern' at the left and remove the initializations.
Move all functions and their associated code from the header files to
new source files. Keep the class definitions and function prototypes
in the header files.
Add a copy of the current include list found in the compta.cpp file to
the top of each of the new source files.
Create a make file which will be used to build the program. This will
allow you to receive errors from only one source file, correct it, and
then never have to recompile it as you work on what errors are found
in the next file and so on.
Using made-up names for the newly created files the make file might
look like this:
-----------------------------------------
.autodepend
OBJS=compta.obj storage.obj code1.obj code2.obj code3.obj \
code4.obj code5.obj code6.obj
compta.exe : $(OBJS)
tlink /Tpe/v/c @&&|
c0l $(OBJS),compta,,emu cl
|
.cpp.obj :
bcc -v -c -4 -ff -N -ml $<
-----------------------------------------
Note the indenting. While the amount of indenting is not sensitive to
the number of spaces used, the fact that something begins in column 1
versus if it is indented is vital to proper operation of the make
file. Also do not overlook the periods that appear in column 1 for
the '.autodepend' and '.cpp.obj :' lines. They are required.
I have retained the -ff which you used in the compiler command line
but note that it is the default so is not needed. I have added '-c'
to tell it to compile but not link and -v to tell it to include debug
information as the program clearly will need debugging. The text of
the file above duplicates what I used after I reconfigured your code
as discussed above. However I did not troubleshoot everything so the
linker command has not yet been executed.
If the file were saved with the default name MAKEFILE then a command
to compile and link to create the program would be:
make
If the file were saved with the name SOMENAME.MAK then the command
would be:
make -f somename.mak
where the space after the -f and the extension .mak are optional.
. Ed
Quote
Morosh wrote in message
news: XXXX@XXXXX.COM ...

done at 13:44 GMT
thanks