BUG: "Too many local, nonstatic variables" Error MessageLast reviewed: January 12, 1998Article ID: Q179140 |
The information in this article applies to:
SYMPTOMSWhen compiling an application that calls functions or subroutines in a DLL and that passes large User Defined Types to the DLL, you may receive the following error:
"Too many local, nonstatic variables" CAUSEThe above error is the result of a bug in the Visual Basic compiler when allocating memory for passing User Defined Types (UDTs) to functions or subroutines in DLLs. The error may occur when this amount exceeds approximately 64KB.
RESOLUTIONYou can work around this problem by changing the way that such UDTs are passed to the DLL. When you pass a UDT to a DLL, you are actually passing a pointer to the first memory location of the UDT. Another way to pass this pointer is by copying the UDT to a Byte array and passing the first element of the Byte array by reference. NOTE: You will need to calculate the size of this Byte array manually, taking into consideration the issues relating to byte-alignment. For more information regarding byte-alignment, refer to Section 6 of the VB5DLL.DOC document located in the Tools\Docs folder of the Visual Basic 5.0 CD-ROM. Because the Visual Basic run-time library converts the strings from UNICODE to ANSI when using the CopyMemory function below, you should only allocate 1 byte for each character in your fixed-length strings. Assuming you have the following UDT and Declare statement for your DLL:
Type LargeUDT nAge as Integer sName As String * 4000 lMiles as Long End Type Dim aLargeUDT As LargeUDT Declare Sub MySub Lib "MYDLL.DLL" (x As LargeUDT)Follow these steps to implement a workaround to the problem:
STATUSMicrosoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this bug and will post new information here in the Microsoft Knowledge Base as it becomes available.
MORE INFORMATION
Steps to Reproduce Behavior
REFERENCESFor additional information on calling subroutines and functions in DLLs, please see the following document: VB5DLL.DOC, Visual Basic 5 CD-ROM (Professional and Enterprise Editions Only), in the following folder ...\TOOLS\DOCS\.
|
Additional query words: UDT
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |