You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@stdcxx.apache.org by Farid Zaripov <Fa...@epam.com> on 2007/08/10 15:58:10 UTC
missprint in include/rw/_mutex.h ?
Below is a part of the include/rw/_mutex.h file, line 116:
-----------
# ifdef _RWSTD_NO_FWD_DECLARATIONS
# include <windows.h>
# define _RWSTD_MUTEX_T _RTL_CRITICAL_SECTION
# else // if defined (_RWSTD_NO_FWD_DECLARATIONS)
// avoid #including this header (MFC doesn't like it)
// # include <windows.h>
-----------
Perhaps there in the first line should be #ifndef instead of #ifdef ?
Farid.
RE: missprint in include/rw/_mutex.h ?
Posted by Farid Zaripov <Fa...@epam.com>.
> -----Original Message-----
> From: Martin Sebor [mailto:sebor@roguewave.com]
> Sent: Friday, August 10, 2007 6:59 PM
> To: stdcxx-dev@incubator.apache.org
> Subject: Re: missprint in include/rw/_mutex.h ?
>
> Farid Zaripov wrote:
> > Below is a part of the include/rw/_mutex.h file, line 116:
> >
> > -----------
> > # ifdef _RWSTD_NO_FWD_DECLARATIONS
> >
> > # include <windows.h>
> > # define _RWSTD_MUTEX_T _RTL_CRITICAL_SECTION
> >
> > # else // if defined (_RWSTD_NO_FWD_DECLARATIONS)
> >
> > // avoid #including this header (MFC doesn't like it)
> > // # include <windows.h>
> > -----------
> >
> > Perhaps there in the first line should be #ifndef instead
> of #ifdef ?
>
> What makes you think that?
Just from comment in #else :)
# ifdef _RWSTD_NO_FWD_DECLARATIONS
# else // if defined (_RWSTD_NO_FWD_DECLARATIONS)
I thought that froward declaration is the #including <windows.h>,
but now I understand that is conversely declaring the function
prototypes instead of #including <windows.h>.
The comment on #else should be // if !defined
(_RWSTD_NO_FWD_DECLARATIONS)
Farid.
Re: missprint in include/rw/_mutex.h ?
Posted by Martin Sebor <se...@roguewave.com>.
Farid Zaripov wrote:
> Below is a part of the include/rw/_mutex.h file, line 116:
>
> -----------
> # ifdef _RWSTD_NO_FWD_DECLARATIONS
>
> # include <windows.h>
> # define _RWSTD_MUTEX_T _RTL_CRITICAL_SECTION
>
> # else // if defined (_RWSTD_NO_FWD_DECLARATIONS)
>
> // avoid #including this header (MFC doesn't like it)
> // # include <windows.h>
> -----------
>
> Perhaps there in the first line should be #ifndef instead of #ifdef ?
What makes you think that?
IIRC, the _RWSTD_NO_FWD_DECLARATIONS macro was put in place to deal
with the changing signatures of the AtomicXxx Windows functions:
Microsoft added volatile in some service pack, causing breakage
in code that forward-declared them. So I think the code is correct.
What makes you think it's not?
Martin
Re: missprint in include/rw/_mutex.h ?
Posted by Martin Sebor <se...@roguewave.com>.
Travis Vitek wrote:
> Well, as it stands the macro is doing exactly what its name indicates it
> will do. If it is defined, the implementation will not use forward
> declarations of the critical section struct and its functions.
>
> I agree that this is a little weird because the default will be for the
> macro to not be defined. The user has to define
> _RWSTD_NO_FWD_DECLARATIONS to get the declarations from the correct and
> normal place [windows.h].
The purpose of the forward declarations is to avoid dragging
in the quarter million lines of code that #include <windows.h>
pulls in to the translation unit. The <windows.h> may be the
correct header to #include but the way it's implemented makes
it horribly inefficient to compile and introduces namespace
pollution on an unprecedented scale (hence Microsoft's own
hacks like VC_EXTRALEAN and WIN32_LEAN_AND_MEAN -- even they
recognize what a mess it is).
I have for a long time been meaning to hide all the preprocessor
ugliness in _mutex.h in a .cpp file and provide a clean interface
to the APIs it defines. I don't think it's too hard to do but like
with all other nice but non-essential projects like this, I haven't
had time to do it. If you feel adventurous and would like to take
a crack at it, be my guest :)
> It seems to me that the macro should be
> _RWSTD_NO_INCLUDE_WINDOWS_H or something similar.
Yeah, I agree, it's not the best name. Now that we have a config
test to determine the signature of the InterlockedXxx functions
and given that the signatures have been stable for some time now
the macro most likely isn't even needed anymore.
Martin
>
> Travis
>
>
>
>> -----Original Message-----
>> From: Farid Zaripov [mailto:Farid_Zaripov@epam.com]
>> Sent: Friday, August 10, 2007 6:58 AM
>> To: stdcxx-dev@incubator.apache.org
>> Subject: missprint in include/rw/_mutex.h ?
>>
>> Below is a part of the include/rw/_mutex.h file, line 116:
>>
>> -----------
>> # ifdef _RWSTD_NO_FWD_DECLARATIONS
>>
>> # include <windows.h>
>> # define _RWSTD_MUTEX_T _RTL_CRITICAL_SECTION
>>
>> # else // if defined (_RWSTD_NO_FWD_DECLARATIONS)
>>
>> // avoid #including this header (MFC doesn't like it)
>> // # include <windows.h>
>> -----------
>>
>> Perhaps there in the first line should be #ifndef instead of #ifdef ?
>>
>> Farid.
>>
RE: missprint in include/rw/_mutex.h ?
Posted by Travis Vitek <tv...@quovadx.com>.
Well, as it stands the macro is doing exactly what its name indicates it
will do. If it is defined, the implementation will not use forward
declarations of the critical section struct and its functions.
I agree that this is a little weird because the default will be for the
macro to not be defined. The user has to define
_RWSTD_NO_FWD_DECLARATIONS to get the declarations from the correct and
normal place [windows.h]. It seems to me that the macro should be
_RWSTD_NO_INCLUDE_WINDOWS_H or something similar.
Travis
>-----Original Message-----
>From: Farid Zaripov [mailto:Farid_Zaripov@epam.com]
>Sent: Friday, August 10, 2007 6:58 AM
>To: stdcxx-dev@incubator.apache.org
>Subject: missprint in include/rw/_mutex.h ?
>
> Below is a part of the include/rw/_mutex.h file, line 116:
>
>-----------
># ifdef _RWSTD_NO_FWD_DECLARATIONS
>
># include <windows.h>
># define _RWSTD_MUTEX_T _RTL_CRITICAL_SECTION
>
># else // if defined (_RWSTD_NO_FWD_DECLARATIONS)
>
> // avoid #including this header (MFC doesn't like it)
> // # include <windows.h>
>-----------
>
> Perhaps there in the first line should be #ifndef instead of #ifdef ?
>
>Farid.
>