A Smart Linking Question 
Author Message
 A Smart Linking Question

   Is there any advantage/penalty to making as many Var declarations as
(a Unit has) variables, where all variables are referenced and bound into
the .EXE?  For example:

Var A,B : byte;

versus...

Var A : byte;
Var B : byte;

   In the first example, it would seem that TP/BP could (would?) pack the
2 variables in the Data Segment, but I wonder if the 2nd would use more
of the Data Segment in some way.  Or are they the same in either case?
   TIA



Wed, 18 Jun 1902 08:00:00 GMT  
 A Smart Linking Question

Quote:

>   Is there any advantage/penalty to making as many Var declarations as
>(a Unit has) variables, where all variables are referenced and bound into
>the .EXE?  For example:

>Var A,B : byte;

>versus...

>Var A : byte;
>Var B : byte;

>   In the first example, it would seem that TP/BP could (would?) pack the
>2 variables in the Data Segment, but I wonder if the 2nd would use more
>of the Data Segment in some way.  Or are they the same in either case?

There is no difference in the result (assuming both variables are
used). However, the latter uses more memory while compiling/linking. The
only thing that affects the packing of variables is $A directive.

Osmo



Wed, 18 Jun 1902 08:00:00 GMT  
 A Smart Linking Question


Quote:
>    Is there any advantage/penalty to making as many Var declarations as
> (a Unit has) variables, where all variables are referenced and bound into
> the .EXE?  For example:

> Var A,B : byte;

> versus...

> Var A : byte;
> Var B : byte;

>    In the first example, it would seem that TP/BP could (would?) pack the
> 2 variables in the Data Segment, but I wonder if the 2nd would use more
> of the Data Segment in some way.  Or are they the same in either case?

They're use the same amount of  space in both cases. However, the latter
case is "smart linker friendly" because the variables are declared in
separate "var" blocks. In the former case, both variables would get linked
in if Either variable is referenced by any code that is linked in.


Wed, 18 Jun 1902 08:00:00 GMT  
 A Smart Linking Question

Quote:
>   Is there any advantage/penalty to making as many Var declarations as
>(a Unit has) variables, where all variables are referenced and bound into
>the .EXE?  For example:

>Var A,B : byte;

>versus...

>Var A : byte;
>Var B : byte;

>   In the first example, it would seem that TP/BP could (would?) pack the
>2 variables in the Data Segment, but I wonder if the 2nd would use more
>of the Data Segment in some way.  Or are they the same in either case?

First example uses less memory when compiling. 2nd is more smart-link
friendly. {$A+/-} changes 'packing' not separate var declarations.

FWIW, I always use the 2nd when declaring variables in both main program
and all units to save on data memory space.

--
Information on Newsgroup posted weekly on Sunday - read before writing!
Contains links to    |  http://homepages.force9.net/Pascal/faq/
helpful information  |  http://www.merlyn.demon.co.uk/clpb-faq.txt
and some guidelines  |  ftp://garbo.uwasa.fi/pc/doc-net/faqclpb.zip



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. SQL Links Question

2. More linked list Question!(please help);

3. Linked List Questions

4. Question about linked lists of records

5. Linked Lists Question

6. Link List question

7. Linked List management question, I need help.

8. SQL Links Question

9. Informix and SQL Links / Also debugging question

10. Question about DLL link. (II)

11. Informix and SQL Links / Also debugging question

12. link fortran to pascal question

 

 
Powered by phpBB® Forum Software