News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

MASM dependency resolving

Started by vid, December 05, 2007, 11:19:07 PM

Previous topic - Next topic

vid

Hi. I have this code:

.586
.model flat, stdcall

EXTERNDEF x:near
s STRUCT
     dd x
s ENDS

.data
.code
start:

end start

Resulting object file includes dependency on "x" even though it is not needed, because structure "s" is never used.

Is there any way to predefine structure member to external value, such, that dependency on external value is created only when structure is used?

thanks in advance

ToutEnMasm

Hello,
a declaration couldn't be extern.Only proc,data (compiled code) could be extern.
For example,in a library

Quote
PUBLIC xxx
sss STRUCT
     thing dd ?
sss ENDS
.data
xxx sss <>

In the source
Quote
sss STRUCT
     thing dd ?
sss ENDS

EXTERNDEF xxx:sss
.code
mov eax,xxx.thing

vid

QuoteOnly proc,data (compiled code) could be extern
I think you are wrong about this. Label can be extern too, and even plain number can be extern (label is just a number too, anyway).

EXTERNDEF x:NEAR is way to declare extern label. It is suposed to include dependency on "x" only if it is used (unlike EXTERN). But in this case, it gets it wrong.


For clarity, here  is what I want, written in FASM:

format MS COFF
if used X
  extrn X
end if
struc S {
  dd X
}
;sss S    <- if commented, no dependency on X produced

if structure S is used, then value of X needs to be known, and dependency on X is produced in resulting file. If structure S is not used, then there is no dependency on X.

ToutEnMasm

Hello,
With masm,you can used definition only in include file or by adding the definition in the source.
There is no equivalent of "If used ....",and you have to add the define of X (if it is a structure) in your source.
If x is a label,he must be declare PUBLIC in the library and EXTERN in the source code and there is no need to test his usage.
You can only test the presence of equate (equ).

vid

But you are still not getting where the problem is.

Symbol defined with EXTERNDEF should create dependency only if it is used in source. In this case it isn't used, but MASM creates dependency