String_char_traits <char> in C ++ 11 for GNU / g ++ 4.9 (previously 2.95.3)

I have legacy C ++ code (used to compile using GNU g ++ 2.95.3) with the following declaration std::basic_string<char,string_char_traits<char>,malloc_alloc> x; The header file was

 #include <std/bastring.h> 

Now I go to g ++ 4.9 GU where I get this error: 1. std/bastring.h not found 2. When I change #include <std/bastring.h> to #include <string> , I get the following error:

 error: 'string_char_traits' was not declared in this scope std::basic_string<char,string_char_traits<char>,malloc_alloc> x; error: template argument 2 is invalid std::basic_string<char,string_char_traits<char>,malloc_alloc> x; error: expected unqualified-id before ',' token std::basic_string<char,string_char_traits<char>,malloc_alloc> x; ^ 

Requires compilation guide / help in GNU g ++ 4.9

+5
source share
1 answer

Despite the publication of ISO / IEC 14882: 1998, GCC 2.95.3 is not a C ++ 98-compatible compiler. We are talking about a 15-year-old compiler working on the goats of the terrible god, who knows that non-standard code since the 90s . Firstly, here is a snippet from bastring.h :

 // Written by Jason Merrill based upon the specification by Takanori Adachi // in ANSI X3J16/94-0013R2. ... // NOTE : This does NOT conform to the draft standard and is likely to change #include <alloc.h> 

I don’t know what ANSI X3J16/94-0013R2 , but it definitely has nothing to do with ISO C ++ 98. malloc_alloc is in alloc.h if for some reason you want to explicitly want to use malloc and free in the distributor.

In any case, your code base will undoubtedly have to be rewritten from scratch. std::basic_string<char,string_char_traits<char>,malloc_alloc> x; can be replaced with std::string . But I shudder from the horrors of what is in another pre-standard code.

+1
source

All Articles