Microsoft KB Archive/42475

= Basic Uses ALIAS to DECLARE C Routines with Underscore in Name =

Article ID: 42475

Article Last Modified on 11/21/2006

-

APPLIES TO


 * Microsoft QuickBasic 4.0
 * Microsoft QuickBASIC 4.0b
 * Microsoft QuickBasic 4.5 for MS-DOS
 * Microsoft BASIC Professional Development System 7.0

-



This article was previously published under Q42475



SUMMARY
To call a Microsoft C routine from QuickBasic, the C routine must first be declared using a DECLARE statement. If the C routine name contains an embedded underscore, which is improper syntax in QuickBasic, you must use the ALIAS clause to give it a valid Basic name.

This information applies to Microsoft QuickBasic versions 4.00, 4.00b, and 4.50, Microsoft Basic Compiler versions 6.00 and 6.00b, and Microsoft Basic Professional Development System (PDS) version 7.00. The references to DECLARE, ALIAS, and CDECL can be found on Pages 142 to 146 of the &quot;Microsoft QuickBasic 4.0: Basic Language Reference&quot; manual.



MORE INFORMATION
C functions added to a library or Quick library have an underscore added to the front of the function name (that is, &quot;my_func&quot; will become &quot;_my_func&quot; in a library). When you DECLARE a C routine in a Basic program, you must use the CDECL clause, which automatically adjusts for the underscore at the front of the routine name.

However, if you want to use the ALIAS clause to DECLARE a C function that has an embedded underscore (for example, &quot;my_func&quot;), the CDECL clause will not add the underscore automatically to the front of the ALIAS name.

The following is an example: REM *** Basic program to call my_func *** DECLARE SUB mysub CDECL ALIAS &quot;_my_func&quot; CALL myfunc END

/* C function with embedded underscore */ void my_func { putch('A'); }

Additional query words: QuickBas BasicCom

Keywords: KB42475

-

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

© Microsoft Corporation. All rights reserved.