Article ID: 57923
This article was previously published under Q57923
This article has been archived. It is offered "as is" and will no longer be updated.
Microsoft QuickC version 2.0 or 2.5 routines that attempt memory allocation [with malloc()] do not allocate any memory when used in a Quick library in the QuickBasic environment. If the pointers are then referenced in the C routine, the following error message halts the program and returns to DOS:
run-time error R6013 - illegal far pointer use
Microsoft has confirmed this to be a bug in Microsoft QuickC versions 2.0 and 2.5 (buglist2.00, buglist2.50); in the QB.EXE editor in Microsoft QuickBasic version 4.5; and in the QBX.EXE (QuickBasic Extended) editor in Microsoft Basic Professional Development System (PDS) versions 7.0 and 7.1 (buglist7.00, buglist7.10). We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.
C routines that use malloc() to allocate memory work correctly when linked with compiled Basic programs. Furthermore, these routines work correctly in Quick libraries when compiled with C Compiler version 5.0 and 5.1.
The following code example causes the above error (R6013) in the QuickBasic environment. The code is the SETMEM example from the QuickBasic QB Advisor online Help system, with one line added to reference the pointer.
Code ExampleThe example below uses the SETMEM function to free memory for a C function that uses the C routine malloc() to get dynamic memory.
Note: To run this program, you must separately compile the C function and put it in a Quick library. The C function must be compiled using the large memory model, so calls to malloc() use the far space freed by the Basic program.
The following are the QuickC and C compiler compiling lines for the above C code:
QCL -c -AL setmemc.c ;To create a Quick library from the C routine, the link line is as follows for QuickBasic 4.5:
CL -c -AL setmemc.c ;
LINK /Q /NOE setmem.c,,,bqlb45.lib;
Article ID: 57923 - Last Review: February 27, 2014 - Revision: 1.2
Contact us for more help
Connect with Answer Desk for expert help.