Microsoft KB Archive/77736

= BUG: Compiled Static Array in SUB, Err 10 Duplicate Definition =

Article ID: 77736

Article Last Modified on 11/21/2006



This article was previously published under Q77736



SYMPTOMS
A compiled program using static arrays implicitly declared in a static SUB will incorrectly give a run-time error 10, &quot;Duplicate Definition,&quot; on the second call to that SUB.

Microsoft has confirmed this to be a bug with the compiler in Microsoft QuickBasic version 1.0b for the Macintosh. Microsoft is researching this problem and will post new information here as it becomes available.

This problem does not occur in programs interpreted in QuickBasic 1.0b.



MORE INFORMATION
The error 10 (&quot;Duplicate Definition&quot;) shows that on the second call to the subprogram, the compiled code mistakenly thinks the array element is being redefined as a different type.

The following steps demonstrate this problem in compiled programs:

  Type the following code in QuickBasic for Macintosh: Call MySub             'First call to SUB. Call MySub             'Second call will cause error.

Sub MySub Static       'This Sub Initializes contents of an array. For i = 0 to 9 MyArray(i) = i  Next i End Sub  From the Run menu, select &quot;Options...&quot; and then make sure the &quot;Make All Arrays Static&quot; box is checked. Compile the program, and run the resulting compiled program.

Here is how you would need to change the above code to have it work properly: Dim MyArray (10)               'Dimension the array at the module level. Call MySub Call MySub

Sub MySub Static Shared MyArray    'Declare the array shared so it uses the same For i = 0 to 9              'array that was DIM'ed at the module level MyArray(i) = i  Next i End Sub

Additional query words: MQuickB 1.00b

Keywords: kbbug KB77736

-

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

© Microsoft Corporation. All rights reserved.