🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.modula2
Article #2923

On TopSpeed's data const_in_code pragma

#2923
From: Bengt-Inge Dalenback
Date: Mon, 23 Oct 1995 10:01
54 lines
2779 bytes
Has anybody ever used the TopSpeed pragma

   data(const_in_code=>on)    ?

The background is that under Windows, space in the default data
segment is very tight with a big app, and using more data segments
(this is large model) will prevent Windows from moving the extra
segments around affecting the performance and also prevents multiple
instances.

There are two basic ways to decrease the data size in the segment.

1) switch on the share_constant project pragma (works fine)

2) move all string literals and similar data to the resource file
(works fine and is the way to go for other reasons too such as
translating to another language).

3) restructure the program to make less use of global module VARs

Even after these three steps, there may be many little things left
that would take a long time to move to the Res-file (and may never
even need to be translated) and they pile up in a big application
(in the Xtd DOS program that I have converted each *module* could
have 32k of data, and I had about 150 modules).

A simple trick (that MS and Borland C++ pulls too) is to use the
"const_in_code" pragma since it puts all initialized data (CONST,
string literals, plain numbers etc.) in the code segment of a module.
It immediately would free up a lot of valuable space.

However, when I apply the pragma at project level. The app won't
even start! If I apply it to one module at a time, it works until
suddenly for one module the app won't start again.

Anybody had any experience with this pragma? For example, does it
(without being documented so) clash with other pragmas? The docs
only says not to use it with the pragma that allows you to assign
to constants (const_assign) since that would give a GPF under
Windows trying to write to a code segment. To me, it looks like it
also ought to clash with the link pragma share_const but if that one
is removed it still does not work with const_in_code.

Ideas?

--------------------------------
Bengt-Inge Dalenback, CATT
also at: 
Department of Applied Acoustics
Chalmers University of Technology
Gothenburg, SWEDEN
e-mail: bid@ta.chalmers.se
fax : +46 31 145154
Technical Details
Message-ID: <46fp57$jjs@nyheter.chalmers.se>
Path: arc1-ca.pugleaf.net!g0-mac7.ta.chalmers.se!bid

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!g0-mac7.ta.chalmers.se!bid
From: Bengt-Inge Dalenback <bid@ta.chalmers.se>
Newsgroups: comp.lang.modula2
Subject: On TopSpeed's data const_in_code pragma
Date: 23 Oct 1995 10:01:11 GMT
Organization: CATT & Dep. of Applied Acoustics, Chalmers
Distribution: world
Message-ID: <46fp57$jjs@nyheter.chalmers.se>
NNTP-Posting-Host: g0-mac7.ta.chalmers.se
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Newsreader: Nuntius 2.0.1_68K
X-XXMessage-ID: <ACB126863901B84A@g0-mac7.ta.chalmers.se>
X-XXDate: Mon, 23 Oct 1995 10:01:26 GMT