[prev in list] [next in list] [prev in thread] [next in thread]
List: hpux-cxx-dev
Subject: Re: CXX-DEV: explicit global scope for std namespace components
From: Xiaohua Zhang <zhang () cup ! hp ! com>
Date: 2000-12-11 23:22:09
[Download RAW message or body]
"Leland T. Snyder" wrote:
>
> We are porting code from HP ANSI C++ B3910B A.01.18 to HP ANSI C++
> B3910B A.03.25 however I am encountering some errors during the
> re-compile I hope you can help me with.
>
> To avoid name clashes some of our code makes explicit references to
> the functions within the std name space, to make the code compatible
> with other compilers we do something odd, which is to have an full
> explicit call to the function with in the code like so:
>
> cout << "test[" << std::isspace(' ') << "]" << endl;
>
> and then compile with the option "-Dstd= "
>
> The problem is that while aCC A.01.18 found the following line
> acceptable
>
> cout << "test[" << ::isspace(' ') << "]" << endl;
>
> aCC A.03.25 throws a compilation error
>
> Error 19: "it.C", line 18 # Unexpected '::'.
> cout << "test[" << ::isspace(' ') << "]" << endl;
>
> The objective is to always avoid name conflict with local scope
> declarations. Below is a simple code example with compile output
> placed in comments after
> the source. Any suggestions ?
>
isspace is a macro in ctype.h, you can use isspace() without qualifier
or put extra () around ::isspace :
cout << "test[" << (::isspace)(' ') << "]" << endl;
or
cout << "test[" << isspace(' ') << "]" << endl;
>
> ===============================================================================
>
> #include <stdcomp.h>
> #ifndef RWSTD_HEADER_REQUIRES_HPP
> #include <vector>
> #else
> #include <vector.hpp>
> #endif
>
> #include <iostream.h>
>
> #ifndef RWSTD_NO_NAMESPACE
> using namespace std;
> #endif
>
>
> int main(int argc, char *argv[])
> {
>
> cout << "test[" << ::isspace(' ') << "]" << endl;
>
> }
>
> /*******************
> $ aCC -V
> aCC: HP ANSI C++ B3910B A.03.25
> $ uname -a
> HP-UX dbkdev01 B.11.00 A 9000/800 140901557 two-user license
>
>
> Error 19: "it.C", line 18 # Unexpected '::'.
> cout << "test[" << ::isspace(' ') << "]" << endl;
>
>
>
> ========================================================================
>
> $ aCC -V
> aCC: HP ANSI C++ B3910B A.01.18
> $ uname -a
> HP-UX yoda B.10.20 A 9000/879 1221075311 two-user license
> $
>
> ^^
>
> "/tmp/it.C" 21 lines, 293 characters
> /usr/ccs/bin/ld: (Warning) At least one PA 2.0 object file (it.o) was
> detected. The linked output may not run on a PA 1.x system.
> test[512]
> $ ./it
> test[512]
>
> *******************/
--
----------------------------
Xiaohua Zhang (zhang@cup.hp.com)
Hewlett-Packard
(408)-447-3247
_________________________________________________________________
To leave this mailing list, send mail to majordomo@cxx.cup.hp.com
with the message UNSUBSCRIBE cxx-dev
_________________________________________________________________
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic