473,748 Members | 7,142 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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/libFormalValida tion/ErrorCache.h:20 :
error: forward declaration of `struct Support::CError Info'

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 4637
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*********@ho tmail.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
4520
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 to gather various different classes into a common namespace using typedefs: class QWidget {}; class MyListview {}; namespace gui
2
3338
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 2 - Changing the constructor of the modeless dialog to accept the parent object:" line and go onwards is what I'm trying to do Basically, there is the main form, and then there's the modeless form. I want the modeless form act like a modal form,...
3
2241
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 <CSharpModule.dll> class CPlusPlusClass
4
1384
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) namespace managedDll { public __value class VecDouble; public __value class VecFloat
0
914
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 the C++ <-> C# interface encapsulated in one C++ module. Vladimir Nesterovsky wrote: > You can add your C# assembly in a project's references thus you may not import it explicitly. > --
3
8861
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
5415
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 want InkFrame to be forward declared in the PrefDialog header file rather than to be included. I want to include it in the cpp file instead. There is no harm including it in PrefDialog header, and it works. But I want to save some compilation time....
1
11603
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
8330
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 device_t { const device_backend_t *backend; ... } device_t; typedef struct device_backend_t {
0
8991
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
8830
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
9541
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9370
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
8242
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4602
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4874
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2782
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2215
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.