468,512 Members | 1,375 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,512 developers. It's quick & easy.

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 3248
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by lomat | last post: by
1 post views Thread by squallions | last post: by
2 posts views Thread by Plok Plokowitsch | last post: by
1 post views Thread by HappyHippy | last post: by
7 posts views Thread by Michael B Allen | last post: by
1 post views Thread by Alex | last post: by
8 posts views Thread by Mohammad Omer Nasir | last post: by
11 posts views Thread by Jef Driesen | last post: by
reply views Thread by NPC403 | last post: by
1 post views Thread by fmendoza | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.