Assembly Language Help (alang.hlp) (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
Define External Variables, Labels, and Symbols
 Example                                   Up Contents Index Back
────────────────────────────────────────────────────────────────────────────
 
  Syntax:   EXTERNDEF [langtype] name:qualifiedtype
            [, [langtype] name:qualifiedtype]...
 
            EXTERN [langtype] name[(altID)]:qualifiedtype
            [, [langtype] name[(altID)]:qualifiedtype]...
 
  See also: EXTERNDEF Diagram, PUBLIC, COMM, PROTO, /C<x>, /H, /Zf,
            MASM 5.1 Compatibility
 
  Description:
 
     The EXTERNDEF directive tells the assembler that one or more
     variables, symbols, data structures, or labels are defined in
     other modules. The behavior of the EXTERNDEF directive is
     determined by its context:
 
        ■ If <name> is used in the current module but is not defined,
          <name> is made external.
        ■ If <name> is defined in the current module, it is made
          PUBLIC.
        ■ If <name> is neither used nor defined, the directive is
          ignored.
 
     The EXTERNDEF directive allows you to put global data declarations
     in an include file without forcing the linker to pull in unneeded
     modules. Usually, you define <name> in one module and put the
     EXTERNDEF directive in a file that is included in all program
     modules. The PROTO directive automatically generates an EXTERNDEF
     for its related procedure.
 
     EXTERN is a less flexible version of EXTERNDEF. It declares
     <name> as external whether or not it is used in the module.
     EXTRN is a synonym for EXTERN and is included for compatibility
     with previous versions of the assembler.
 
     With the EXTERN directive, <name> can be followed by (altID),
     which allows the linker to select an alternate resolution for
     <name>. This is useful when creating library files.
 
     Parameter     Description
 
     langtype      A language type appropriate to <name>.
                   See: language type
 
     name          A unique global symbolic name. Case mapping is
                   overridden by OPTION CASEMAP.
 
     qualifiedtype The qualified type to be given to <name>. Can
                   also be ABS, which causes <name> to be imported
                   as a constant. Does not have to match type given
                   to <name> in original definition.
                   See: qualified type
 
     altID         A unique global symbolic name to use as an alternate
                   for <name>. Must be of the same type as <name>. The
                   <altID> parameter cannot be declared as a <name>
                   with an altID in an EXTERN statement in this or any
                   other module.
 
     In MASM 5.1, you must place an EXTRN directive for a variable in the
     same segment that holds the variable. For far data, this often entails
     opening and closing a segment just to place the EXTRN statement.
 
     In MASM 6.1, this same-segment requirement does not apply with the
     EXTERN and EXTERNDEF statements. The only requirement is that
     they aren't located in the wrong segment. In compatibility mode,
     however, MASM 6.1 emulates the behavior of MASM 5.1.
                                    -♦-