473,698 Members | 1,991 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

struct ptr within the same struct

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
Feb 19 '06 #1
5 1840
Ufit wrote:
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
--
Please remove capital As from my address when replying by mail
Feb 19 '06 #2

"Victor Bazarov" <v.********@com Acast.net> wrote in message

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

_Item *pPointer;
}
---
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
Feb 19 '06 #3
TB
Ufit skrev:

"Victor Bazarov" <v.********@com Acast.net> wrote in message

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

_Item *pPointer;
}

---

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 ?


http://www.parashift.com/c++-faq-lite/

--
TB @ SWEDEN
Feb 19 '06 #4
Ufit wrote:
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

Feb 19 '06 #5
"Ufit" <ko************ **@NOpoczta.fm> wrote in message
news:dt******** **@news.onet.pl
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;
};
--
John Carson
Feb 20 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
9065
by: Steven T. Hatton | last post by:
The following may strike many of you as just plain silly, but it represents the kind of delelima I find myself in when trying to make a design decision. This really is a toy project written for the purpose of learning to work with C++. It therefore makes some sense for me to give the situation the amount of consideration presented below. To be quite honest, I'm amazed at the amount there is to say about such a seemingly simple...
6
2687
by: S.Tobias | last post by:
I'm trying to understand how structure type completion works. # A structure or union type of unknown # content (as described in 6.7.2.3) is an incomplete type. It # is completed, for all declarations of that type, by ^^^ # declaring the same structure or union tag with its defining # content later in the same scope. ^^^^^ (6.2.5#23)
15
43552
by: Ken Allen | last post by:
I have some code from C/C++ that I am attempting to port to C#. I have come across an interesting problem that is quite common in complex C/C++ code: the us of UNION in structure definitions to permit the same piece of memory to be referenced as different data types. This is often used to save space and permit a single piece of memory to contain different types of data, typically based on some other flag in the structure. In other cases...
4
4026
by: DaHool | last post by:
Hi there !!! I browsed around the Internet in search for a solution of a little difficult problem i have in VB.NET.... However, i cannot find a suitable anwser anywhere, so i thought i'll give it a try here... Okay, here's the deal: I am trying to read from unmanaged memory with a class type struct, this
45
18872
by: Zytan | last post by:
This returns the following error: "Cannot modify the return value of 'System.Collections.Generic.List<MyStruct>.this' because it is not a variable" and I have no idea why! Do lists return copies of their elements? Why can't I change the element itself? class Program { private struct MyStruct
18
2180
by: lovecreatesbea... | last post by:
1. The following code snippet uses minus operation on two pointers to calculate the distance between struct members. This is illegal, right? 2. s1 and s2 are type of the same struct S. Can the distance of s1.i4 between i3 be used to deduce the distance between s2.i4 and s2.i3? Thank you for your time. #include <stdio.h>
5
7222
by: emmanuel.rivoire | last post by:
Hello, I spent almost a week to be able to embed Python within my C++ game engine. I wrote a mini-tutorial of what I was able to do so far here : http://forums.indiegamer.com/showpost.php?p=169352&postcount=9 At the end of my tutorial, I wrote : "You can do the same with C++ classes, and with structures within structures. Swig can parse & wrap most C/C++ declarations."
4
2778
by: Sheldon | last post by:
Hi, I have a unique case where I need an array of structs that grows and within this array is another struct that grows in some cases. I'm having trouble allocating memory. Since I have never done this before, I'm sure it's a rookie mistake but I cannot seem to find it. Can someone render some assistance please? struct Fpos { grib_handle *h;
6
368
by: BIll Cunningham | last post by:
pg 128 of kandr2 speaks of a struct struct point{ int x; int y; }; I understand this but what is it saying about using intialize variables like such.
4
1845
by: Lew Pitcher | last post by:
(having trouble getting my reply through - hopefully, third time is a charm) On November 11, 2008 19:53, in comp.lang.c, BIll Cunningham (nospam@nspam.invalid) wrote: Why an int? Because K&R chose to use an int. Why not a double? Because K&R chose to use an int. Note the phrase "syntactically analogous". It means that the /syntax/ of
0
8673
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8601
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9021
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8860
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4614
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3043
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2327
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1998
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.