BUG: L2029 When Using struct with "volatile" Keyword

Last reviewed: July 22, 1997
Article ID: Q104244
7.00 | 1.00 1.50 MS-DOS | WINDOWS kbprg kbbuglist

The information in this article applies to:

  • The Microsoft C/C++ Compiler (CL.EXE) included with:

        - Microsoft C/C++ for MS-DOS, version 7.0
        - Microsoft Visual C++ for Windows, versions 1.0 and 1.5
    

SYMPTOMS

A communal (that is, global and uninitialized) structure declaration of a variable with the "volatile" type qualifier is not resolved at link time. The result is an unresolved external (L2029 error) on the declared variable. For example, if the following code

   struct a { int x; } volatile v;

   main() {
     v.x=3;
   }

is placed in a TEST.C file and is compiled with the default compiler and linker options, the linker will return:

   error L2029: '_v' : unresolved external

RESOLUTION

Use one of the following three workarounds:

  • Use the C++ compiler. This error does not occur with the C++ compiler. If the file is changed to TEST.CPP (in the example above) then it will build without generating this error.

    -or-

  • Initialize the variable. This error only occurs if a noninitializing communal declaration is used.

          struct a { x; } volatile v = { 3 };
    

    -or-

  • Declare the structure with a tag and use the tag later to declare the variable:

          struct a { x; };
          struct a volatile v;
    

STATUS

Microsoft has confirmed this to be a bug in C/C++ versions 7.0 and 8.0 for MS-DOS and C/C++ version 7.0 for OS/2. This problem does not occur with the Microsoft Visual C++ 32-bit edition.


Additional reference words: 1.00 1.50 1.00 7.00 8.00 8.00c
KBCategory: kbprg kbbuglist
KBSubcategory: CLIss
Keywords : kb16bitonly


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 22, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.