473,403 Members | 2,284 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,403 software developers and data experts.

Forward class redefinition problem

Hi,
I have the following problem

The below class is fully defined in the header file thus there's no
..cpp-file. The header-file is included in several lib's I'm using.
----------
#pragma once
class CCriticalSectionGuard ;

class CCriticalSection
{
friend class CCriticalSectionGuard ;
..
..
};

class CCriticalSectionGuard
{
..
..
};
--------
Now I use this class in several other classes but when I compile the
compiler (Visual Studio 2005) gives me the following error statement:
error C2011: 'CCriticalSection' : 'class' type redefinition
CriticalSectionGuard.h

Thinking of it I get this when I try to compile into a .dll but not
when I compile into a .lib (which I use in the .dll-file) and they
basically uses the same libs. Anyone got any inputs?
I've checked the following things: there's no duplicate files in any
include paths, there's no duplication of the class name in any other
include file. All project headers starts with the #pragma once
directive (thus adding #ifndef wont help - I've tried that as well...).

Please help,
Martin

Jul 26 '06 #1
1 3579
Ma***************@gmail.com wrote:
I have the following problem

The below class is fully defined in the header file thus there's no
.cpp-file. The header-file is included in several lib's I'm using.
----------
#pragma once
This is implementation-defined. If you have problems because of it,
we can't help you. Contact the newsgroup dedicated to your compiler.
class CCriticalSectionGuard ;
You don't need a forward-declaration for a friend declaration, IIRC.
class CCriticalSection
{
friend class CCriticalSectionGuard ;
.
.
};

class CCriticalSectionGuard
{
.
.
};
--------
Now I use this class in several other classes but when I compile the
compiler (Visual Studio 2005) gives me the following error statement:
error C2011: 'CCriticalSection' : 'class' type redefinition
CriticalSectionGuard.h
WHERE? I mean, on which line with the word 'CCriticalSection'? You
got at least three of them here.
Thinking of it I get this when I try to compile into a .dll but not
DLLs are off-topic, sorry.
when I compile into a .lib (which I use in the .dll-file) and they
basically uses the same libs. Anyone got any inputs?
Somebody in the newsgroup where DLLs are on topic should.
I've checked the following things: there's no duplicate files in any
include paths, there's no duplication of the class name in any other
include file. All project headers starts with the #pragma once
directive (thus adding #ifndef wont help - I've tried that as
well...).
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Jul 26 '06 #2

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

Similar topics

5
by: lomat | last post by:
Hello, While compiling a file, I get following error .... ================================= /usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.3/include/g++/type_traits.h:14 2: redefinition of...
1
by: squallions | last post by:
Hi I doing my c++ homework and stuck on error 'class' type redefinition. I have 5 classes. First class is base class. The next two classes are derived from the first class. The next two...
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...
1
by: HappyHippy | last post by:
Hi, I have a question about forward declaration of classes. First of all, a simple working example, which compiles and works with no problems. ///file class_a.h:/ #ifndef __CLASS_A_H__...
7
by: Michael B Allen | last post by:
I have a forward reference like: struct foo; int some_fn(struct foo *param); Because the parameter is a pointer the compiler is satisfied. But now I wan to change 'struct foo' to a...
1
by: Alex | last post by:
Hello all, I have a very stupid problem that is driving me crazy...so plz if anyone ever saw this, I would like him to help me :) I have static MFC application in MSVC++ 6.0 (named Example)....
3
by: DhaneshNair | last post by:
Hi all, I hav a file which is actually linkage file (used as an reference interface between c and c++ files). And this file has got two structures in it .. When i include this file directly i...
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( ) {
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
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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,...
0
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...
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.