c++/3309: 'string' typedef bug

Artem Khodush artem@duma.gov.ru
Thu Jun 21 01:51:00 GMT 2001


> #include <string>
> 
> 
> class Test
> {
>   public:
> 
>   typedef int IntType;
>   typedef string StringType;
> };
> 
>test.cxx:11: ISO C++ forbids declaration of `string' with no type
>test.cxx:11: parse error before `;' token

This is not a bug, though the error message is
somewhat misleading. Gcc 3.0 is much closer 
to c++ standard then 2.95, so <string> header 
does not define class string in the global 
namespace anymore.

Either write 
    typedef std::string StringType;
or
    using std::string; // just after including <string>






More information about the Gcc-bugs mailing list