astreambuf.h error in the beta release

Nov 15, 2013 at 9:14 PM
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 {
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

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

Nov 15, 2013 at 9:54 PM
#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("");

  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;

  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.

Nov 21, 2013 at 11:59 PM
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.