PRB: L2029 Error from Unsized Array Declaration at File Scope

Last reviewed: July 24, 1997
Article ID: Q66775

The information in this article applies to:
  • The Linker (LINK.EXE) included with: - Microsoft C for MS-DOS, versions 5.1, 5.1a, 6.0, 6.0a, 6.0ax - Microsoft C for OS/2, versions 5.1, 6.0, 6.0a - Microsoft C/C++ for MS-DOS, version 7.0 - Microsoft Visual C++ for Windows, versions 1.0, 1.5 - Microsoft Visual C++, 32-bit Edition, versions 1.0, 2.0, 5.0

SYMPTOMS

An attempt to link an application fails and Microsoft LINK generates the following message:

   L2029: unresolved external

CAUSE

The application declares an unsized array at file scope, and does not contain another declaration at file scope that specifies the size for the array.

RESOLUTION

Modify the source code of one of the modules to declare the array with its correct size at file scope.

MORE INFORMATION

Because an unsized array declaration at file scope is considered external, the C compiler cannot determine whether or not the size is omitted intentionally, and the compiler does not generate an error message.

The following sample code demonstrates this situation:

Sample Code

   int Array[];

   void main(void)
   {
      printf("%d.\n", Array);
   }

To address this situation, create another source file that declares Array to have a size (for example, "int Array[2]"), and compile and link the two modules.


Keywords : LinkIss kbfasttip
Version : 5.1 6.0 6.0a 6.0ax 7.0 1.0 1.5 2
Issue type : kbprb


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 24, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.