Microsoft KB Archive/104244

{|
 * width="100%"|

BUG: L2029 When Using struct with "volatile" Keyword

 * }

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

Issue type : kbbug

Technology : kbVCsearch kbAudDeveloper kbCVCComp