473,399 Members | 3,106 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,399 software developers and data experts.

forward declaration with namespace

I have sources containing lots of namespaces (even nested ...)

I'm porting these classes to gcc 3.3.2. At the moment I get several
error messages like this:

../../src/libFormalValidation/ErrorCache.h:20:
error: forward declaration of `struct Support::CErrorInfo'

The code at this place is:

namespace Support
{
class CErrorInfo; // <- here
}

This is a forward declaration of a class located in a namespace. This
class name will be used later for pointers, references and template
parameters. This is legal on MSVC and on HPUX aCC. Is this illegal on
gcc?

T.M.
Aug 26 '05 #1
3 4622
your forward declaration declares CErrorInfo as a class. however, the
error message referes to CErrorInfo as a struct. is it a class or a
struct?

stoyan.

Aug 26 '05 #2
"nymano" <pl*********@hotmail.com> schrieb:
your forward declaration declares CErrorInfo as a class. however, the
error message referes to CErrorInfo as a struct. is it a class or a
struct?


"class" is a special case of "struct". gcc uses the more common word
"struct" in it's error messages which means both classes and structs.

My code contains the following definition:

namespace Support {
class CErrorInfo
{
// ...
};
}

My guess is: classes declared forward are not usable as template
parameter type later. But I can't imagine this really.

T.M.
Aug 26 '05 #3
Torsten Mueller wrote:
<snip>
My guess is: classes declared forward are not usable as
template parameter type later. But I can't imagine this
really.

<snip>

Whether or not a template instantiation needs the type
definition depends on the template. E.g.
std::tr1::smart_ptr<T> doesn't need T's full type to
instantiate any member function (AFAIR, except when you
use the default value of the 2nd ctor argument - the
deleter).
std::pair<U,V> need the full type, though.

The forward declaration you have posted is completely ok.
The problem lies elsewhere. Post more code, and an error
message.

Marc

Aug 26 '05 #4

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

Similar topics

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...
2
by: Legendary Pansy | last post by:
Hello, I'm trying to accomplish the impossible by trying to do something equivalent of this example found here http://www.c-sharpcorner.com/Code/2003/Dec/DialogTutorial.as Starting with "Listing...
3
by: Eckart Haug | last post by:
I'm working with C# objects from managed C++ using the gcroot template. There'a a C++ header containing the definition of a C++ class: #using <mscorlib.dll> #include <vcclr.h> #using...
4
by: Jerome | last post by:
Hi all, I'm trying to use forward declaration with value class but I don't succeed in compiling my (quite simple) sample code. This is my code I'm trying to compile (Visual Studio 2003) ...
0
by: Eckart Haug | last post by:
Thanx for the quick reply. Your suggestion would mean that I'd have to add a C# reference to any C++ module that includes the C++ header. There's lots of them and I'd (for the moment) like to have...
3
by: yancheng.cheok | last post by:
hello all, how can i make, a forward declaration class's enum member, being visible by another class? consider the following case, ---------------------------- dog.h...
1
by: toton | last post by:
Hi, I have two namespace contains class InkFrame and PrefDialog respectively. PrefDialog needs InkFrame to show the dialog over the frame. It also stores a pointer to InkFrame inside it. Now I...
1
by: dj | last post by:
How can I make a forward declaration of a class that is defined in some other namespace? E.g.: file1.h: namespace A { class A {...}; } file2.h:
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.