struct ptr within the same struct

U

Ufit

Compiling the following code (C++):

struct _Item
{
int var1;
.......

_Item *pPointer;


}

under VS6.0 I get no errors but under VS2003 I get error using undefined type.
What is the solution to correctly compile the program using VS2003.
PS VS'06 does the same thing. Please help.
Thanks

Uf
 
V

Victor Bazarov

Ufit said:
Compiling the following code (C++):

struct _Item

The identifier "_Item" is reserved for the implementation. Don't
use it.
{
int var1;
.......

_Item *pPointer;


}

under VS6.0 I get no errors but under VS2003 I get error using
undefined type. What is the solution to correctly compile the program
using VS2003.

I get the syntax error at the line with the dots. When I compile this
program:

struct Item {
int i;
Item* pPointer;
};

int main() {
Item item;
}

with VC++ v7.1 (2003), I get no errors. Read the FAQ 5.8.

V
 
U

Ufit

Victor Bazarov said:
The identifier "_Item" is reserved for the implementation. Don't
use it.
---

with VC++ v7.1 (2003), I get no errors. Read the FAQ 5.8.
I actualy use _xItem - but doesn't matter what name is used - error comes up.
Where's that faq 5.8 ?

U
 
L

Luke Meyers

Ufit said:
I actualy use _xItem - but doesn't matter what name is used - error comes up.

The problem is the leading underscore, not the alphanumerics that
follow.

Luke
 
J

John Carson

Ufit said:
Compiling the following code (C++):

struct _Item
{
int var1;
.......

_Item *pPointer;


}

under VS6.0 I get no errors but under VS2003 I get error using
undefined type. What is the solution to correctly compile the program
using VS2003. PS VS'06 does the same thing. Please help.
Thanks

Uf

My guess is that you are compiling this as C code, not C++ code. For it to
compile as C code, you need to use struct, i.e.,

struct Item
{
int var1;
struct Item *pPointer;
};
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top