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/10/24 19:36:26 UTC

ios_bits.cpp and MSVC

  I'm working on STDCXX-437 issue and I've removed almost all MSVC 6.0
code, but I found some #if expression that I don't understand.


src/ios_bits.cpp, line 84
--------------------
#if !defined (_MSC_VER) || (_MSC_VER <= 1300)

_RWSTD_DEFINE_STATIC_CONST (const ios_base::seekdir ios_base::beg);
_RWSTD_DEFINE_STATIC_CONST (const ios_base::seekdir ios_base::cur);
_RWSTD_DEFINE_STATIC_CONST (const ios_base::seekdir ios_base::end);

#endif // !defined (_MSC_VER) || (_MSC_VER <= 1300)
--------------------

  This part of code used only on non-MSVC and MSVC <= 7.0.
So these lines are excluded only on MSVC > 7.0. Why?

  BTW the same definitions of the static constants are present
in src/ctype_bits.cpp but withound any #if expressions:

src/ctype_bits.cpp, line 39
--------------------
_RWSTD_DEFINE_STATIC_CONST (const ctype_base::mask ctype_base::space);
_RWSTD_DEFINE_STATIC_CONST (const ctype_base::mask ctype_base::print);
_RWSTD_DEFINE_STATIC_CONST (const ctype_base::mask ctype_base::cntrl);
_RWSTD_DEFINE_STATIC_CONST (const ctype_base::mask ctype_base::upper);
_RWSTD_DEFINE_STATIC_CONST (const ctype_base::mask ctype_base::lower);
_RWSTD_DEFINE_STATIC_CONST (const ctype_base::mask ctype_base::alpha);
_RWSTD_DEFINE_STATIC_CONST (const ctype_base::mask ctype_base::digit);
_RWSTD_DEFINE_STATIC_CONST (const ctype_base::mask ctype_base::punct);
_RWSTD_DEFINE_STATIC_CONST (const ctype_base::mask ctype_base::xdigit);
_RWSTD_DEFINE_STATIC_CONST (const ctype_base::mask ctype_base::alnum);
_RWSTD_DEFINE_STATIC_CONST (const ctype_base::mask ctype_base::graph);
--------------------

  The ctype_base::mask and ios_base::seekdir both are typedefs
_RWSTD_BITMASK_ENUM (...):

include/loc/_ctype.h, line 73:
    typedef _RWSTD_BITMASK_ENUM (_RW::__rw_ctype_mask) mask;

include/rw/_iosbase.h, line 202:
    typedef _RWSTD_BITMASK_ENUM (_RW::__rw_seekdir) seekdir;

Farid.

RE: ios_bits.cpp and MSVC

Posted by Farid Zaripov <Fa...@epam.com>.
> -----Original Message-----
> From: Martin Sebor [mailto:sebor@roguewave.com] 
> Sent: Friday, October 26, 2007 2:59 AM
> To: stdcxx-dev@incubator.apache.org
> Subject: RE: ios_bits.cpp and MSVC
> 
> 
> 
> Farid Zaripov-2 wrote:
> > 
> > [...]
> >> http://issues.apache.org/jira/browse/STDCXX-613
> > 
> >   This bug avoided in _defs.h:
> > 
> > _defs.h, line 1020:
> > -----------
> > #  ifndef _RWSTD_NO_STATIC_CONST_MEMBER_DEFINITION
> > #    define _RWSTD_DEFINE_STATIC_CONST(decl)   decl
> > #  else   // if defined (_RWSTD_NO_STATIC_CONST_MEMBER_DEFINITION)
> >      // disable defintion of static const integral members
> >      // to work around compiler bugs such as those in MSVC
> >      // or Intel C++/Windows that cause multiple definition
> >      // linker errors (see PR #26562 and #30260)
> > #    define _RWSTD_DEFINE_STATIC_CONST(ignore)   /* empty */
> > #  endif   // _RWSTD_NO_STATIC_CONST_MEMBER_DEFINITION
> > -----------
> > 
> >   I've commented the #if !defined (_MSC_VER) || (_MSC_VER 
> <= 1300) and 
> > corresponding #endif lines in ios_bits.cpp, and the test 
> shows no any 
> > errors.
> > 
> > 
> 
> I assume you couldn't find anything in the ChangeLog?

  Correct.

> I'll have to check the Perforce log at Rogue Wave to see if I can 
> find any clues as to why the conditional is there when I'm 
> back in the office (I'm out sick today and possibly 
> tomorrow). But if you've tested the code after removing it 
> (I'd do several different build types just to be sure) and 
> didn't see problems I'd say it should be a safe change to make.

  This definitely can't cause any problem because of the lines from
_defs.h above and the following lines from _config-msvcrt.h (see below)
the _RWSTD_DEFINE_STATIC_CONST macro always #defined to
/* empty */ on all MSVC and ICC/Windows.

_config-msvcrt.h:
---------------
#ifndef _RWSTD_NO_STATIC_CONST_MEMBER_DEFINITION
     // both MSVC 7.x and Intel C++/Windows allow "inline" initializers
     // for static const integral data members but out-of-line
definitions
     // cause multiply defined symbol errors (see PR #26562 and #30260)
     // disable their definitions in source files (the members are still
     // declared)
#  define _RWSTD_NO_STATIC_CONST_MEMBER_DEFINITION
#endif   // _RWSTD_NO_STATIC_CONST_MEMBER_DEFINITION
---------------

Farid.

RE: ios_bits.cpp and MSVC

Posted by Martin Sebor <se...@roguewave.com>.

Farid Zaripov-2 wrote:
> 
> [...]
>> http://issues.apache.org/jira/browse/STDCXX-613
> 
>   This bug avoided in _defs.h:
> 
> _defs.h, line 1020:
> -----------
> #  ifndef _RWSTD_NO_STATIC_CONST_MEMBER_DEFINITION
> #    define _RWSTD_DEFINE_STATIC_CONST(decl)   decl
> #  else   // if defined (_RWSTD_NO_STATIC_CONST_MEMBER_DEFINITION)
>      // disable defintion of static const integral members
>      // to work around compiler bugs such as those in MSVC
>      // or Intel C++/Windows that cause multiple definition
>      // linker errors (see PR #26562 and #30260)
> #    define _RWSTD_DEFINE_STATIC_CONST(ignore)   /* empty */
> #  endif   // _RWSTD_NO_STATIC_CONST_MEMBER_DEFINITION
> -----------
> 
>   I've commented the #if !defined (_MSC_VER) || (_MSC_VER <= 1300)
> and corresponding #endif lines in ios_bits.cpp, and the test shows no
> any errors.
> 
> 

I assume you couldn't find anything in the ChangeLog? I'll have to check
the Perforce log at Rogue Wave to see if I can find any clues as to why
the conditional is there when I'm back in the office (I'm out sick today and
possibly tomorrow). But if you've tested the code after removing it (I'd do
several different build types just to be sure) and didn't see problems I'd
say it should be a safe change to make.

Martin
-- 
View this message in context: http://www.nabble.com/ios_bits.cpp-and-MSVC-tf4685822.html#a13418440
Sent from the stdcxx-dev mailing list archive at Nabble.com.


RE: ios_bits.cpp and MSVC

Posted by Farid Zaripov <Fa...@epam.com>.
> -----Original Message-----
> From: Martin Sebor [mailto:sebor@roguewave.com] 
> Sent: Wednesday, October 24, 2007 8:58 PM
> To: stdcxx-dev@incubator.apache.org
> Subject: Re: ios_bits.cpp and MSVC
> 
> Farid Zaripov wrote:
> >   I'm working on STDCXX-437 issue and I've removed almost 
> all MSVC 6.0 
> > code, but I found some #if expression that I don't understand.
> > 
> > 
> > src/ios_bits.cpp, line 84
> > --------------------
> > #if !defined (_MSC_VER) || (_MSC_VER <= 1300)
> > 
> > _RWSTD_DEFINE_STATIC_CONST (const ios_base::seekdir ios_base::beg); 
> > _RWSTD_DEFINE_STATIC_CONST (const ios_base::seekdir ios_base::cur); 
> > _RWSTD_DEFINE_STATIC_CONST (const ios_base::seekdir ios_base::end);
> > 
> > #endif // !defined (_MSC_VER) || (_MSC_VER <= 1300)
> > --------------------
> > 
> >   This part of code used only on non-MSVC and MSVC <= 7.0.
> > So these lines are excluded only on MSVC > 7.0. Why?
> 
> I suspect it's a workaround for the following bug that first 
> appeared in MSVC 7.0:
> http://lab.msdn.microsoft.com/ProductFeedback/viewfeedback.asp
> x?feedbackid=b9853206-740a-47e7-af09-b03b51934a97
> 
> The Microsoft Feedback site gives me an error again when I 
> try to access the page but I copied the issue from the Rogue 
> Wave bug tracking database where we keep track of it to STDCXX-613:
> 
> http://issues.apache.org/jira/browse/STDCXX-613

  This bug avoided in _defs.h:

_defs.h, line 1020:
-----------
#  ifndef _RWSTD_NO_STATIC_CONST_MEMBER_DEFINITION
#    define _RWSTD_DEFINE_STATIC_CONST(decl)   decl
#  else   // if defined (_RWSTD_NO_STATIC_CONST_MEMBER_DEFINITION)
     // disable defintion of static const integral members
     // to work around compiler bugs such as those in MSVC
     // or Intel C++/Windows that cause multiple definition
     // linker errors (see PR #26562 and #30260)
#    define _RWSTD_DEFINE_STATIC_CONST(ignore)   /* empty */
#  endif   // _RWSTD_NO_STATIC_CONST_MEMBER_DEFINITION
-----------

  I've commented the #if !defined (_MSC_VER) || (_MSC_VER <= 1300)
and corresponding #endif lines in ios_bits.cpp, and the test shows no
any errors.

Farid.

Re: ios_bits.cpp and MSVC

Posted by Martin Sebor <se...@roguewave.com>.
Farid Zaripov wrote:
>   I'm working on STDCXX-437 issue and I've removed almost all MSVC 6.0
> code, but I found some #if expression that I don't understand.
> 
> 
> src/ios_bits.cpp, line 84
> --------------------
> #if !defined (_MSC_VER) || (_MSC_VER <= 1300)
> 
> _RWSTD_DEFINE_STATIC_CONST (const ios_base::seekdir ios_base::beg);
> _RWSTD_DEFINE_STATIC_CONST (const ios_base::seekdir ios_base::cur);
> _RWSTD_DEFINE_STATIC_CONST (const ios_base::seekdir ios_base::end);
> 
> #endif // !defined (_MSC_VER) || (_MSC_VER <= 1300)
> --------------------
> 
>   This part of code used only on non-MSVC and MSVC <= 7.0.
> So these lines are excluded only on MSVC > 7.0. Why?

I suspect it's a workaround for the following bug that first
appeared in MSVC 7.0:
http://lab.msdn.microsoft.com/ProductFeedback/viewfeedback.aspx?feedbackid=b9853206-740a-47e7-af09-b03b51934a97

The Microsoft Feedback site gives me an error again when I try
to access the page but I copied the issue from the Rogue Wave
bug tracking database where we keep track of it to STDCXX-613:

http://issues.apache.org/jira/browse/STDCXX-613

Martin

> 
>   BTW the same definitions of the static constants are present
> in src/ctype_bits.cpp but withound any #if expressions:
> 
> src/ctype_bits.cpp, line 39
> --------------------
> _RWSTD_DEFINE_STATIC_CONST (const ctype_base::mask ctype_base::space);
> _RWSTD_DEFINE_STATIC_CONST (const ctype_base::mask ctype_base::print);
> _RWSTD_DEFINE_STATIC_CONST (const ctype_base::mask ctype_base::cntrl);
> _RWSTD_DEFINE_STATIC_CONST (const ctype_base::mask ctype_base::upper);
> _RWSTD_DEFINE_STATIC_CONST (const ctype_base::mask ctype_base::lower);
> _RWSTD_DEFINE_STATIC_CONST (const ctype_base::mask ctype_base::alpha);
> _RWSTD_DEFINE_STATIC_CONST (const ctype_base::mask ctype_base::digit);
> _RWSTD_DEFINE_STATIC_CONST (const ctype_base::mask ctype_base::punct);
> _RWSTD_DEFINE_STATIC_CONST (const ctype_base::mask ctype_base::xdigit);
> _RWSTD_DEFINE_STATIC_CONST (const ctype_base::mask ctype_base::alnum);
> _RWSTD_DEFINE_STATIC_CONST (const ctype_base::mask ctype_base::graph);
> --------------------
> 
>   The ctype_base::mask and ios_base::seekdir both are typedefs
> _RWSTD_BITMASK_ENUM (...):
> 
> include/loc/_ctype.h, line 73:
>     typedef _RWSTD_BITMASK_ENUM (_RW::__rw_ctype_mask) mask;
> 
> include/rw/_iosbase.h, line 202:
>     typedef _RWSTD_BITMASK_ENUM (_RW::__rw_seekdir) seekdir;
> 
> Farid.