This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
user allocator portability
- From: "Xiaowen (Jason) Liu" <jasonliu at cs dot dartmouth dot edu>
- To: libstdc++ at gcc dot gnu dot org
- Date: Sun, 23 Jun 2002 23:51:37 -0400
- Subject: user allocator portability
Hi.
I've been trying to write my owner memory allocator for shared memory
multiprocessors. It seemed straightforward for STL, until I try to make
it portable among different versions of gcc on different platforms.
I have a memory allocator called MyAlloc, defined in such a way that all
allocators should be. I'm using 'map' and 'set'. In order to make a
consistent view of memory, I need to make 'string' to use it as well. So
I defined them in the following way:
typedef
basic_string<char,string_char_traits<char>,MyAlloc<char> >
__string;
typedef
map<__string,void*,less<__string>,MyAlloc<__string> >
__map_string_pvoid;
It certainly worked fine on my laptop. (I attached the information of
the gcc installed on my laptop). However, I run into trouble when
compiling it on the Solaris machine and on Mac OS X darwin (a BSD
variant). They gave me the following error message:
`string_char_traits' was not declared in this scope
parse error before `>' token
`__string' was not declared in this scope
`less' was not declared in this scope
`__string' was not declared in this scope
ISO C++ forbids declaration of `map' with no type
template-id `map<<expression error>,
void*, <expression error> >' used as a declarator
`__string' was not declared in this scope
Obviously, the compiler cannot find string_char_traits and less.
Changing string_char_traits to char_traits doesn't help. I'm just
wondering if I'm hitting somewhere where stdc++ is not portable at all.
Or, is char_traits not supposed to be used by regular users? Then how am
I suppose to have a portable allocator? I'm developing software that
portability is the most important factor.
Thanks for any help.
--
Xiaowen (Jason) Liu (jasonliu@cs.dartmouth.edu)
---------------------------------------------------------------
Computer Science Department ISTS, Cybersecurity Research Group
Dartmouth College Dartmouth College
6211 Sudikoff Laboratory 45 Lyme Road, Suite 201
Hanover, NH 03755 Hanover, NH 03755
Telephone: 603-646-0676 Fax: 603-646-0660
WWW Home Page: http://www.cs.dartmouth.edu/~jasonliu/
---------------------------------------------------------------
Here is info of the gcc I'm using on my laptop:
% cpp -v -x c++ /dev/null /dev/null
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/2.96/specs
gcc version 2.96 20000731 (Red Hat Linux 7.1 2.96-97)
/usr/lib/gcc-lib/i386-redhat-linux/2.96/cpp0 -lang-c++ -D__EXCEPTIONS
-v -D__ELF__ -Dunix -Dlinux -D__ELF__ -D__unix__ -D__linux__ -D__unix
-D__linux -Asystem(posix) -D__NO_INLINE__ -Acpu(i386) -Amachine(i386)
-Di386 -D__i386 -D__i386__ -D__tune_i386__ /dev/null -o /dev/null
GNU CPP version 2.96 20000731 (Red Hat Linux 7.1 2.96-97) (cpplib) (i386
Linux/ELF)
ignoring nonexistent directory "/usr/i386-redhat-linux/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/include/g++-3
/usr/local/include
/usr/lib/gcc-lib/i386-redhat-linux/2.96/include
/usr/include
End of search list.
Here's the gcc on the Solaris machine I'm having trouble with:
% cpp -v -x c++ /dev/null /dev/null
Reading specs from /usr/local/lib/gcc-lib/sparc-sun-solaris2.8/3.0.3/specs
Configured with: ../configure --with-as=/usr/local/bin/as
--with-ld=/usr/local/bin/ld --enable-libgcj
Thread model: posix
gcc version 3.0.3
/usr/local/lib/gcc-lib/sparc-sun-solaris2.8/3.0.3/cpp0 -lang-c++
-D__GXX_DEPRECATED -D__EXCEPTIONS -D__GXX_ABI_VERSION=100 -v -Dsparc
-Dsun -Dunix -D__svr4__ -D__SVR4 -D__sparc__ -D__sun__ -D__unix__
-D__svr4__ -D__SVR4 -D__sparc -D__sun -D__unix -Asystem=unix
-Asystem=svr4 -D__NO_INLINE__ -D__STDC_HOSTED__=1 -D_XOPEN_SOURCE=500
-D_LARGEFILE_SOURCE=1 -D_LARGEFILE64_SOURCE=1 -D__EXTENSIONS__
-D__GCC_NEW_VARARGS__ -Acpu=sparc -Amachine=sparc /dev/null -o /dev/null
GNU CPP version 3.0.3 (cpplib) (sparc)
ignoring nonexistent directory "/usr/local/sparc-sun-solaris2.8/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include/g++-v3
/usr/local/include/g++-v3/sparc-sun-solaris2.8
/usr/local/include/g++-v3/backward
/usr/local/include
/usr/local/lib/gcc-lib/sparc-sun-solaris2.8/3.0.3/include
/usr/include
End of search list.