"Unresolved external" With DECLARE and CDECL in a VB Form

ID: Q93676


The information in this article applies to:
  • Microsoft Visual Basic Standard and Professional Editions for MS-DOS, version 1.0


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 "unresolved external" 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:

  1. 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.


  2. 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 "_prt" () 


  3. 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 :
Version : MS-DOS:1.0
Platform : MS-DOS
Issue type :


Last Reviewed: December 9, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.