Microsoft KB Archive/93676

= &quot;Unresolved external&quot; With DECLARE and CDECL in a VB Form =

PSS ID Number: 93676

Article Last Modified on 1/9/2003

-

The information in this article applies to:


 * Microsoft Visual Basic for MS-DOS 1.0

-



This article was previously published under Q93676



SYMPTOMS
If you declare a mixed language SUB procedure or FUNCTION that uses the CDECL keyword, the CDECL keyword is ignored if the DECLARE statement appears in the module level of a form. This problem only occurs in a compiled program and causes the LINK.EXE error L2029 &quot;unresolved external&quot; to occur when LINKing the program together.



WORKAROUND
Listed below are some suggested ways to work around this problem.


 * Use the Pascal calling convention in the non-Basic language module.
 * Use the ALIAS keyword in your declaration.
 * Call the procedure from a non-form Basic module.



STATUS
Microsoft has confirmed this to be a bug in the Standard and Professional Editions of Microsoft Visual Basic for MS-DOS, version 1.0. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.



MORE INFORMATION
When creating a program that uses procedures compiled in another language, it may be desirable to use the CDECL keyword when declaring those procedures in Basic. Usually, when you compile a program using the CDECL keyword, the DECLARE statement is converted to a reference to the equivalent function in the other language and written to the object (.OBJ) file. One other feature of the CDECL keyword is that it appends an underscore to the beginning of that procedure name and converts all the letters to lowercase before writing it to the object (.OBJ) file. For example, by default, when compiling a routine in C, the routine name is also preceded by an underscore. In Visual Basic for MS-DOS, if you declare a procedure using the CDECL keyword in a form, the procedure name written to the object (.OBJ) file is just the name of the procedure in capital letters with no additional underscore. This is the way it would work if you did not specify the CDECL keyword.

The following are three possible workarounds to this problem:

 The easiest way to work around this problem is to compile the other non-Basic routine with the Pascal Calling convention. Depending on the language used, there may either be a compile option or another way to declare the procedure so that it uses this convention.  Another way to work around this problem is to use the ALIAS keyword when you declare the procedure in Basic. The following declaration for the procedure PRT works in either a form or Basic module: DECLARE SUB prt CDECL ALIAS &quot;_prt&quot;  You can also work around this problem by declaring all external procedures in the program in a separate Basic module. From the form you can call a procedure in the Basic module that calls the external procedure.

Additional query words: VBmsdos BUGLIST1.00 1.00

Keywords: KB93676

Technology: kbAudDeveloper kbVB100DOS kbVBSearch kbZNotKeyword3

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© 2004 Microsoft Corporation. All rights reserved.