potential identifier collision in locale_facets.h

scott snyder snyder@fnal.gov
Sat Apr 1 00:00:00 GMT 2000


hi -

I ran into a problem with the locale headers the other day.
Just including <locale> works fine, but for this input:

------------------------------
int mask();
#include <locale>
------------------------------

i get a slew of errors, starting with

In file included from inst/include/g++-v3/bits/std_locale.h:38,
                 from inst/include/g++-v3/locale:2,
                 from x.cc:2:
inst/include/g++-v3/bits/locale_facets.h:169: parse error before `,'
inst/include/g++-v3/bits/locale_facets.h:173: type specifier omitted for parameter

Note that i build with the std:: namespace enabled and with a current
cvs version of g++ (20000306); that may make a difference here.

Line 169 of locale_facets.h is

      is(mask __m, char_type __c) const

so we're picking up the wrong declaration of `mask' here.

A fix is to explicitly qualify the references to mask with
ctype_base, as in the appended.

thanks,
sss

2000-03-08  scott snyder  <snyder@fnal.gov>

	* bits/locale_facets.h: Change all references to `mask' to
	`ctype_base::mask', in order to avoid collisions with the global 
	namespace.

Index: bits/locale_facets.h
===================================================================
RCS file: /cvs/libstdc++/libstdc++/bits/locale_facets.h,v
retrieving revision 1.17
diff -u -p -r1.17 locale_facets.h
--- locale_facets.h	2000/03/07 06:24:35	1.17
+++ locale_facets.h	2000/03/09 18:48:09
@@ -166,19 +166,22 @@ namespace std
 
     public:
       bool 
-      is(mask __m, char_type __c) const
+      is(ctype_base::mask __m, char_type __c) const
       { return this->do_is(__m, __c); }
 
       const char_type*
-      is(const char_type *__lo, const char_type *__hi, mask *__vec) const   
+      is(const char_type *__lo, const char_type *__hi,
+         ctype_base::mask *__vec) const   
       { return this->do_is(__lo, __hi, __vec); }
 
       const char_type*
-      scan_is(mask __m, const char_type* __lo, const char_type* __hi) const
+      scan_is(ctype_base::mask __m, const char_type* __lo,
+              const char_type* __hi) const
       { return this->do_scan_is(__m, __lo, __hi); }
 
       const char_type*
-      scan_not(mask __m, const char_type* __lo, const char_type* __hi) const
+      scan_not(ctype_base::mask __m, const char_type* __lo,
+               const char_type* __hi) const
       { return this->do_scan_not(__m, __lo, __hi); }
 
     protected:
@@ -189,18 +192,18 @@ namespace std
       ~_Ctype() { }
 
       virtual bool 
-      do_is(mask __m, char_type __c) const = 0;
+      do_is(ctype_base::mask __m, char_type __c) const = 0;
 
       virtual const char_type*
       do_is(const char_type* __lo, const char_type* __hi, 
-	    mask* __vec) const = 0;
+	    ctype_base::mask* __vec) const = 0;
 
       virtual const char_type*
-      do_scan_is(mask __m, const char_type* __lo, 
+      do_scan_is(ctype_base::mask __m, const char_type* __lo, 
 		 const char_type* __hi) const = 0;
 
       virtual const char_type*
-      do_scan_not(mask __m, const char_type* __lo, 
+      do_scan_not(ctype_base::mask __m, const char_type* __lo, 
 		  const char_type* __hi) const = 0;
     };
 
@@ -221,25 +224,25 @@ namespace std
       ~ctype() { }
 
       virtual bool 
-      do_is(mask , char_type) const
+      do_is(ctype_base::mask , char_type) const
       {
 	// XXX Need definitions for these abstract mf's.
       }
 
       virtual const char_type*
-      do_is(const char_type*, const char_type*, mask*) const
+      do_is(const char_type*, const char_type*, ctype_base::mask*) const
       {
 	// XXX Need definitions for these abstract mf's.
       }
 
       virtual const char_type*
-      do_scan_is(mask, const char_type*, const char_type*) const
+      do_scan_is(ctype_base::mask, const char_type*, const char_type*) const
       {
 	// XXX Need definitions for these abstract mf's.
       }
 
       virtual const char_type*
-      do_scan_not(mask, const char_type*, const char_type*) const
+      do_scan_not(ctype_base::mask, const char_type*, const char_type*) const
       {
 	// XXX Need definitions for these abstract mf's.
       }
@@ -303,11 +306,11 @@ namespace std
     {
     private:
       // Data Members:
-      bool 			_M_del;
-      __to_type const& 		_M_toupper;
-      __to_type const& 		_M_tolower;
-      const mask* const& 	_M_ctable;
-      const mask* 		_M_table;
+      bool 				_M_del;
+      __to_type const& 			_M_toupper;
+      __to_type const& 			_M_tolower;
+      const ctype_base::mask* const& 	_M_ctable;
+      const ctype_base::mask* 		_M_table;
       
     public:
       // Types:
@@ -317,30 +320,33 @@ namespace std
       static const size_t      table_size = 1 + static_cast<unsigned char>(-1);
 
       explicit 
-      ctype(const mask* __table = 0, bool __del = false, 
+      ctype(const ctype_base::mask* __table = 0, bool __del = false, 
 	    size_t __refs = 0) throw();
 
       inline bool 
-      is(mask __m, char __c) const throw();
+      is(ctype_base::mask __m, char __c) const throw();
  
       inline const char*
-      is(const char* __low, const char* __high, mask* __vec) const throw();
+      is(const char* __low, const char* __high,
+         ctype_base::mask* __vec) const throw();
  
       inline const char*
-      scan_is(mask __m, const char* __low, const char* __high) const throw();
+      scan_is(ctype_base::mask __m, const char* __low,
+              const char* __high) const throw();
 
       inline const char*
-      scan_not(mask __m, const char* __low, const char* __high) const throw();
+      scan_not(ctype_base::mask __m, const char* __low,
+               const char* __high) const throw();
      
     protected:
       virtual 
       ~ctype();
 
-      inline const mask* 
+      inline const ctype_base::mask* 
       table() const throw()
       { return _M_table; }
 
-      inline const mask* 
+      inline const ctype_base::mask* 
       classic_table() throw()
       { return _M_ctable; }
 
@@ -381,9 +387,9 @@ namespace std
     class ctype<wchar_t> : public _Ctype<wchar_t>
     {
      private:
-      __to_type const& 		_M_toupper;
-      __to_type const& 		_M_tolower;
-      const mask* const& 	_M_ctable;
+      __to_type const& 			_M_toupper;
+      __to_type const& 			_M_tolower;
+      const ctype_base::mask* const& 	_M_ctable;
       static const int _S_table_size = 	ctype<char>::table_size;
       
     public:
@@ -400,18 +406,18 @@ namespace std
       ~ctype();
 
       virtual bool 
-      do_is(mask __m, char_type __c) const;
+      do_is(ctype_base::mask __m, char_type __c) const;
 
       virtual const char_type*
       do_is(const char_type* __lo, const char_type* __hi, 
-	    mask* __vec) const;
+	    ctype_base::mask* __vec) const;
 
       virtual const char_type*
-      do_scan_is(mask __m, const char_type* __lo, 
+      do_scan_is(ctype_base::mask __m, const char_type* __lo, 
 		 const char_type* __hi) const;
 
       virtual const char_type*
-      do_scan_not(mask __m, const char_type* __lo, 
+      do_scan_not(ctype_base::mask __m, const char_type* __lo, 
 		  const char_type* __hi) const;
 
       virtual char_type 


More information about the Libstdc++ mailing list