错误 C2825:"F":后跟 '::' 时必须是类或命名空间
error C2825: 'F': must be a class or namespace when followed by '::'
我在分析代码中错误的原因时遇到了一点麻烦。我的代码看起来很好,其他开发人员也说它很好:
void handle_read_headers(const boost::system::error_code& err, RESTClient::response& resp)
{
if (!err)
{
// Start reading remaining data until EOF.
boost::asio::async_read(socket_, response_,
boost::asio::transfer_at_least(1),
boost::bind(&client::handle_read_content, this,
boost::asio::placeholders::error,
boost::asio::placeholders::bytes_transferred,
boost::ref(resp)));
}
}
void handle_read_content(const boost::system::error_code& ec, size_t bytes_transferred, RESTClient::response& resp)
{
if (!ec)
{
// Write all of the data that has been read so far.
std::cout << &response_;
// Continue reading remaining data until EOF.
boost::asio::async_read(socket_, response_,
boost::asio::transfer_at_least(1),
boost::bind(&client::handle_read_content, this,
boost::asio::placeholders::error));
}
}
完整的源代码可以在这里找到:http://bit.ly/1gnemqG
错误如下
Error 1 error C2825: 'F': must be a class or namespace when followed by '::' C:localboost_1_58_0boostbindbind.hpp 69 1 HttpClientDemo
Error 2 error C2039: 'result_type' : is not a member of '`global namespace'' C:localboost_1_58_0boostbindbind.hpp 69 1 HttpClientDemo
Error 3 error C2146: syntax error : missing ';' before identifier 'type' C:localboost_1_58_0boostbindbind.hpp 69 1 HttpClientDemo
Error 4 error C2208: 'boost::_bi::type' : no members defined using this type C:localboost_1_58_0boostbindbind.hpp 69 1 HttpClientDemo
Error 5 error C1903: unable to recover from previous error(s); stopping compilation C:localboost_1_58_0boostbindbind.hpp 69 1 HttpClientDemo
这段代码可能有什么问题?
在client::handle_read_content
中,对boost::bind
的调用缺少参数。它应该与client::handle_read_headers
:
boost::asio::async_read(socket_, response_,
boost::asio::transfer_at_least(1),
boost::bind(&client::handle_read_content, this,
boost::asio::placeholders::error,
boost::asio::placeholders::bytes_transferred, // this line was missing
boost::ref(resp) // this line was missing
)
);
相关文章:
- 命名空间中具有.h和.cpp文件的类
- 从父命名空间重载类型
- 在命名空间中定义函数还是限定函数
- C++:对不存在的命名空间使用命名空间指令
- 通过继承类使用来自不同命名空间的运算符
- 使用命名空间时出现多个定义错误
- CUDA内核和数学函数的显式命名空间
- 嵌套的匿名命名空间
- CMakeLists.txt中的命名空间表示法
- 类是C++中的命名空间吗
- 在命名空间中使用全局命名空间中的函数
- 如何使 std::sort 在 std::swap 和我的命名空间的模板化交换之间没有名称冲突?
- '使用命名空间{嵌套在另一个命名空间中的某个命名空间}"
- C++ Visual Studio 错误:名称后跟'::'必须是类或命名空间名称 (DirectX 11)
- 名称后跟"::"必须是类或命名空间错误,即使"::"后面是类名
- 模板类内的成员到函数指针给出错误:后跟 '::' 时必须是类或命名空间
- C++ & GLM: 名称后跟 :: 必须是类或命名空间名称 (Visual Studio 2015)
- 错误 C2825:"F":后跟 '::' 时必须是类或命名空间
- 错误:名称后跟"::"必须是类或命名空间名称
- C++ 错误:名称后跟'::'必须是类或命名空间名称。DLL 中的 WindowsForm