PRB: L2029/L2001 Unsized Array Declaration at File Scope [utilities]

ID: Q66775


The information in this article applies to:


SYMPTOMS

An attempt to link an application fails and Microsoft LINK generates the following messages.

With Microsoft C/C++ 16-bit compilers:
L2029: unresolved external
With Microsoft C/C++ 32-bit compilers:
LNK2001: unresolved external symbol


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.

Additional query words:


Keywords          : kbVC100 kbVC150 kbVC200 kbVC500 kbVC600 LinkIss 
Version           : winnt:1.0,2.0,4.0,5.0,6.0
Platform          : winnt 
Issue type        : kbprb 

Last Reviewed: July 14, 1999