Nick Heiner
Nick Heiner

Reputation: 122450

C++: Can't use std::wstringstream

For some reason, my project won't compile when I try to create a wstringstream:

std::wstringstream stringstream;

This causes error C2079:

'stringstream' uses undefined class 'std::basic_stringstream<_Elem, _Traits, _Alloc> with [_Elem=wchar_t, _Traits=std::char_traits, _Alloc=std::allocator'

What am I doing wrong?

Upvotes: 3

Views: 7386

Answers (3)

Abhay
Abhay

Reputation: 7180

The compiler complains that wstringstream is undefined. Normally if unicode is enabled this call should be included when you include sstream. Right-click your VC++ project, set :-

Configuration Properties -- > General -- > Character Set --> "Use Unicode Character Set"

See if this works for you...

Upvotes: 0

Artyom
Artyom

Reputation: 31233

Include <sstream> header

Upvotes: 16

bshields
bshields

Reputation: 3593

I think your problem is the stringstream variable name. The compiler is recognizing it as a type. Try changing the variable name to something else as a test.

Upvotes: 2

Related Questions