PRB: C2517, C2653, or C2600 If Local Struct Contains Class. (129596)
The information in this article applies to:
- Microsoft Visual C++ for Windows, 16-bit edition 1.5
- Microsoft Visual C++ for Windows, 16-bit edition 1.51
- Microsoft Visual C++ for Windows, 16-bit edition 1.52
- Microsoft Visual C++, 32-bit Editions 2.0
- Microsoft Visual C++, 32-bit Editions 2.1
- Microsoft Visual C++, 32-bit Editions 4.0
This article was previously published under Q129596 SYMPTOMS
In a C++ program, when you define a local struct, class, or union in which
one or more of the fields contains a struct, class, or union type that
defines member functions, the compiler generates these compiler errors:
In Visual C++ versions 1.5x:
Error C2517 : 'S' : right of '::' is undefined
Error C2270 : 'S' : modifiers not allowed on nonmember functions
Error C2561 : 'S' : function must return a value
Error C2510 : 'S' : left of '::' must be a class/struct/union
Error C2084 : function 'S' already has a body
In Visual C++ versions 2.x:
Error C2653 : 'S' : is not a class name
Error C2561 : 'S' : function must return a value
Error C2084 : function 'int _cdecl S(void)' already has a body
In Visual C++ version 4.0:
error C2600: 'a' : uses 'A' in local class 'S' causing compiler-
generated special member functions
error C2601: functions cannot be defined in local classes
Using any MFC classes in the local structure will also cause this problem.
CAUSE
Function definitions are found in a local struct, class, or union
definition. Support for member functions of local classes is part of the
current draft of the C++ Working Paper, but they are not currently
supported by Microsoft Visual C++. They will be supported in a future
release of Microsoft Visual C++.
RESOLUTION
To work around the problem, choose one of the following two methods: STATUS
This behavior is by design.
Modification Type: | Major | Last Reviewed: | 10/24/2003 |
---|
Keywords: | kbCompiler kbCPPonly kberrmsg kbprb KB129596 |
---|
|