2011-02-16 4 views
1
내가 다음 코드를 컴파일하려고

:basic_string 예상 초기화 컴파일 오류

stringtest.cpp:5: error: expected initializer before ‘<’ token 
stringtest.cpp:6: error: ‘foostring’ does not name a type 

제 컴파일러는 다음과 같습니다 : 나는 다음과 같은 오류 얻을

#include <string.h> 
using namespace std; 
typedef std::basic_string<char> foostring; 
foostring foo = "foo"; 

g ++ (우분투 4.4.1-4ubuntu9를) 4.4.1
무엇이 잘못 되었나요? 내가 그것을 사용하는 방법을 알아낼 유니 코드 지원을 위해 Windows TCHAR와 함께 이것을 사용하고자합니다.

답변

4

헤더의 길이는 <string.h>이 아니라 <string>입니다.

표준 라이브러리 헤더는 확장자로 끝나지 않습니다. (당신은 C 헤더에 을 통해 C++에 포함되어야하는 C 헤더 string.h을 포함하고 있습니다. 실제로는 당신이 원했던 것이 었습니다.)

+0

고맙습니다. – alius