Basic PDS ALIAS Example on Page 430 Can Give LINK Error L2029 (73654)






This article was previously published under Q73654

SUMMARY

The DECLARE statement on page 430 of the "Microsoft Basic 7.0: Programmer's Guide" (for versions 7.0 and 7.1) under the example on "Using ALIAS" is incomplete. The incomplete DECLARE statement is listed in the manual as follows:
   DECLARE FUNCTION QuadResult% ALIAS "quad_result" (a, b, c)
				
The explanation of the DECLARE statement implies that the FUNCTION "quad_result" is to be used with a C function. If you create a standard C function called quad_result and attempt to link the compiled code to a Basic program that calls the function, you will receive a "L2029: Unresolved external" error at link time. The problem is that the DECLARE FUNCTION example is designed for a function that uses the Pascal naming and calling convention, not the C naming and calling convention. In order for the example to work with a standard C function, the DECLARE FUNCTION example needs to be changed in the following two ways:

  1. Add the CDECL clause before ALIAS.
  2. Append an underscore to the beginning of the ALIAS name. For example, change "quad_result" to "_quad_result".
The DECLARE statement on page 430 should thus be changed as follows:
   DECLARE FUNCTION QuadResult% CDECL ALIAS "_quad_result" (a, b, c)
				
This information applies to Microsoft Basic Professional Development System (PDS) versions 7.0 and 7.1 for MS-DOS and MS OS/2.

MORE INFORMATION

For more information on how the ALIAS clause works, query on the following words:

alias AND underscore


Modification Type: Minor Last Reviewed: 1/8/2003
Keywords: KB73654