使用url编译错误

compile error with urdl

本文关键字:错误 编译 url 使用      更新时间:2023-10-16

我下载了http库urdl,试图从文档(http://think-async.com/Urdl/doc/html/urdl/getting_started/setting_options_to_perform_an_http_post.html):

)编译示例。
#define URDL_HEADER_ONLY 1
#include <boost/array.hpp>
#include <urdl/http.hpp>
#include <urdl/istream.hpp>

int main() {
    urdl::istream is;
    is.set_option(urdl::http::request_method("POST"));
    is.set_option(urdl::http::request_content_type("text/plain"));
    is.set_option(urdl::http::request_content("Hello, world!"));
    is.open("http://somehost/path");
}

编译错误:

g:boostboost/asio/detail/handler_invoke_helpers.hpp(37) : error C2666: 'urdl::
detail::asio_handler_invoke' : 3 overloads have similar conversions
        g:urdlincludeurdl/detail/http_read_stream.hpp(488): could be 'void ur
dl::detail::asio_handler_invoke<Function>(const Function &,urdl::detail::http_re
ad_stream<Stream>::read_handler<Handler> *)' [found using argument-dependent loo
kup]
        with
        [
....

环境是Win7+VS2010,你知道吗?

谢谢。

是的,你是对的,在新版本的boost中添加了一个名为asio_handler_invoke的模板函数,它与在"http_read_stream.hpp(488)"定义的函数冲突。解决方法是注释用户定义的函数

在boost asio header "handler_invoke_helpers.hpp"中更改:

using boost::asio::asio_handler_invoke;
asio_handler_invoke(function, boost::asio::detail::addressof(context));

boost::asio::asio_handler_invoke(function, boost::asio::detail::addressof(context));