473,692 Members | 3,147 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 CCriticalSectio nGuard ;

class CCriticalSectio n
{
friend class CCriticalSectio nGuard ;
..
..
};

class CCriticalSectio nGuard
{
..
..
};
--------
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: 'CCriticalSecti on' : 'class' type redefinition
CriticalSection Guard.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 3599
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 CCriticalSectio nGuard ;
You don't need a forward-declaration for a friend declaration, IIRC.
class CCriticalSectio n
{
friend class CCriticalSectio nGuard ;
.
.
};

class CCriticalSectio nGuard
{
.
.
};
--------
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: 'CCriticalSecti on' : 'class' type redefinition
CriticalSection Guard.h
WHERE? I mean, on which line with the word 'CCriticalSecti on'? 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
4999
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 `struct __type_traits<short int>' /usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.3/include/g++/type_traits.h:10 2: previous definition here =================================
1
24325
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 classes are derived from previous two classes. On the main file, I have... #include "hw6a.h" #include "hw6b.h"
2
4509
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
1
5705
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__ #define __CLASS_A_H__
7
15274
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 typedef'd type like 'foo_t'. The following all fail to compile:
1
3510
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). That application is built by one company and its usage is to show functionality of their static libraries. Now I created dynamic link library CoreLibrary and I want to integrate it into this example. CoreLibrary worked properly with win32...
3
4101
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 dont have any issues. but according to some norms in the review I am not supposed to use this file direclty in the header file .. but its fine if i use that inside the corresponding file. To avoid compiler error, i forward declared the structure...
8
28460
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
8315
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
8611
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
8549
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
9094
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...
1
8814
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7642
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...
1
6468
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5823
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
4332
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...
2
2244
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.