L1126 Link Error May Be Caused By EXPORT in PROC Definition

ID Number: Q72849

6.00 | 6.00

MS-DOS | OS/2

buglist6.00

Summary:

When creating an exported function with the Microsoft Macro Assembler

(MASM) version 6.0, the EXPORT keyword can be used in a procedure

definition and MASM will automatically generate the correct .OBJ

record to add it to the export table for the .EXE (or DLL). This is

useful when creating a procedure in a DLL that is called from outside

the DLL, when creating a callback procedure in an .EXE, or when

defining a procedure as residing in an IOPL segment with OS/2.

However, there is a problem when the EXPORT keyword is used in the

latter case. When creating an IOPL function, you must declare the

number of words that will be required to hold the parameters for the

function. The operating system then uses this value to build the stack

that the IOPL function will run on. You normally do this by adding the

word count after the function name in the EXPORT section of the

associated .DEF file. For example, the .DEF file may contain the

following:

EXPORTS _Func 3

The problem results when you then use the EXPORT keyword in MASM for

the procedure definition for the IOPL function as follows:

Func PROC EXPORT, arg1:WORD, arg2:WORD, arg3:WORD

MASM will generate an EXPDEF (EXPort DEFinition) record that lists the

parameter word count as zero. If you then link with the .DEF file that

correctly lists the word count as three, the linker will return the

following error message:

fatal error L1126: conflicting pwords value

The sample code illustrates this situation. The only workaround in

this case is to change the EXPORT keyword in the procedure definition

to PUBLIC.

Microsoft has confirmed this to be a problem in MASM version 6.0. We

are researching this problem and will post new information here as it

becomes available.

Sample Code

-----------

TEST.ASM

--------

; Assemble options needed: none

.286

.MODEL large

.DATA

.CODE

Func PROC C EXPORT, arg1:PTR DWORD, arg2:WORD

Func ENDP

end Func

TEST.DEF

--------

; Module definition file for linking

NAME Test

EXPORTS

_Func 3