473,378 Members | 1,393 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

forward declaration for typedef of unnamed structs

Hi all,

Is it possible to do a forward declaration for a typedef of an
incomplete anonymous struct? for example, if I have a type declared
(in a 3rd part header file that I cannot modify) as:

typedef struct
{
...
} mytype;

how can I forward declare such mytype type?

thanks in advance,

Jordi Vilar
Nov 14 '05 #1
5 31142
"Jordi Vilar" <jo*********@hotmail.com> wrote in message
news:5b**************************@posting.google.c om...
Is it possible to do a forward declaration for a typedef of an
incomplete anonymous struct? for example, if I have a type declared
(in a 3rd part header file that I cannot modify) as:

typedef struct
{
...
} mytype;

how can I forward declare such mytype type?


You could if the structure had a tag. You are in bad luck with anonymous
structures. One more reason to avoid typedefing structures.

Peter
Nov 14 '05 #2

"Peter Pichler" <pi*****@pobox.sk> wrote in message:

typedef struct
{
...
} mytype;

how can I forward declare such mytype type?
You could if the structure had a tag. You are in bad luck with

anonymous structures. One more reason to avoid typedefing structures.


At best, this is one more reason to avoid anonymous structures.

Jonathan
Nov 14 '05 #3
Jordi Vilar wrote:
Hi all,

Is it possible to do a forward declaration for a typedef of an
incomplete anonymous struct? for example, if I have a type declared
(in a 3rd part header file that I cannot modify) as:

typedef struct
{
...
} mytype;

how can I forward declare such mytype type?

thanks in advance,

Jordi Vilar


Maybe the author had something that seemed to be a good reason to
make it anonymous and to have only one of them running around.

--
Jukka Helle (Squider) <http://squidysoft.tk/>
Nov 14 '05 #4
jo*********@hotmail.com (Jordi Vilar) wrote:
# Hi all,
#
# Is it possible to do a forward declaration for a typedef of an
# incomplete anonymous struct? for example, if I have a type declared
# (in a 3rd part header file that I cannot modify) as:
#
# typedef struct
# {
# ...
# } mytype;
#
# how can I forward declare such mytype type?

typedef struct A A;
typedef struct B B;

struct A {
B *b;
};
struct B {
A *a;
};

--
Derk Gwen http://derkgwen.250free.com/html/index.html
We found a loophole; they can't keep us out anymore.
Nov 14 '05 #5

"Derk Gwen" <de******@HotPOP.com> wrote in message
news:10*************@corp.supernews.com...
jo*********@hotmail.com (Jordi Vilar) wrote:
# Hi all,
#
# Is it possible to do a forward declaration for a typedef of an
# incomplete anonymous struct? for example, if I have a type declared # (in a 3rd part header file that I cannot modify) as:
#
# typedef struct
# {
# ...
# } mytype;
#
# how can I forward declare such mytype type?

typedef struct A A;
typedef struct B B;

struct A {
B *b;
};
struct B {
A *a;
};


How does this solve the original problem?

Jonathan
Nov 14 '05 #6

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

Similar topics

3
by: mjm | last post by:
Folks, Please help me with the following problems: ******************************************** 1. I have a class template template<class Base> class Matrix : public Base { /* .... */ }
5
by: Jordi Vilar | last post by:
Hi all, Is it possible to do a forward declaration for a typedef of an incomplete anonymous struct? for example, if I have a type declared (in a 3rd part header file that I cannot modify) as: ...
2
by: Marcin Kalicinski | last post by:
Hi All, In some headers meant to work with both C and C++ the following is often found: typedef struct tagMyStruct { /*some members*/ } MyStruct; Can I forward-declare MyStruct somehow? ...
2
by: Jorge Yáñez | last post by:
Hello, It's possible to do a forward declaration of a typedef? Something similar to typedef TMyType; // typedef forward declaration void f ( TMyType& t )
2
by: Plok Plokowitsch | last post by:
After over a decade of programming in C++ I seem to have missed some substantial point (mental note: am I getting too old for this?). A little bit of help would be *very* appreciated. I'm trying...
23
by: mark.moore | last post by:
I know this has been asked before, but I just can't find the answer in the sea of hits... How do you forward declare a class that is *not* paramaterized, but is based on a template class? ...
28
by: Tom Plunket | last post by:
Hey gang; In C++ I often used forward declarations to allow me to get away with not including additional files in headers, if in fact all I needed was to know that a type existed. e.g. ...
8
by: Mohammad Omer Nasir | last post by:
Hi, i made a structure in header file "commonstructs.h" is: typedef struct A { int i; A( ) {
7
by: RedLars | last post by:
Need some help with a couple of questions. Previously I have seen this declaration; struct Student { int age; char name; }; and this definition of an object; struct Student stud;
11
by: Jef Driesen | last post by:
I have the following problem in a C project (but that also needs to compile with a C++ compiler). I'm using a virtual function table, that looks like this in the header file: typedef struct...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.