astreambuf.h error in the beta release

Nov 15, 2013 at 10:14 PM
Hi,
I managed to compile this version under Linux Mint but when I try to use it, I get this error in this section:
.......

ifndef _MS_WINDOWS

// TFS 579628 - 1206: figure out how to avoid having this specialization for Linux (beware of 64-bit Linux)
namespace std {
template<>
error here --->>> struct char_traits<unsigned char> : private char_traits<char>
.............

The error is:
.....
/Release/include/cpprest/astreambuf.h|65|error: specialization of ‘std::char_traits<unsigned char>’ after instantiation
/Release/include/cpprest/astreambuf.h|65|error: redefinition of ‘struct std::char_traits<unsigned char>’
/usr/include/c++/4.8/bits/char_traits.h|227|error: previous definition of ‘struct std::char_traits<unsigned char>’

The compiler is g++ 4.8

G.
Nov 15, 2013 at 10:17 PM
Could you please share the source code and what headers are being included?

Thanks
Kavya.
Nov 15, 2013 at 10:54 PM
// C++ REST SDK
#include <pplx/pplx.h>
#include <pplx/pplxtasks.h>
#include <cpprest/http_client.h>

// the code is something like this:

void TestCasablanca()
{
  web::http::client::http_client client("http://www.microsoft.com");

  client.request(methods::GET).then([](http_response response)
  {
      // Print the status code.
      cout << "Server returned returned status code " << response.status_code() << '.' << std::endl;
      cout << "Content length is " << response.headers().content_length() << " bytes." << std::endl;
  }).wait();

  cout << "Http call finished" << endl;
} // TestCasablanca
Please note that in my test cases I have more code but, this is what I just try to compile and it did not.

G.
Nov 22, 2013 at 12:59 AM
Hi gt227

I tried the code snippet you provided and it works fine for me. I can compile both 32 bit and 64 bit binaries and they run without issues.
Can you provide some more details:
  • Could you please share the Makefile contents used to build the code.
  • Were you able to build the http_client tests or our samples?
    Tests are under Release\tests\Functional\http\client
    Samples are under Release\samples. The BingRequest sample demonstrates creating a http_client and sending a request.
    Let us know if these samples also fail to build.
Thanks
Kavya.