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 "Microsoft QuickBasic 4.0: Basic Language Reference" 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, "my_func" will become "_my_func" 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, "my_func"), 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 "_my_func" CALL myfunc END /* C function with embedded underscore */ void my_func() { putch('A'); }
Additional query words: QuickBas BasicCom
Keywords: KB42475