我正在尝试使用boost库类来进行一些套接字通信。我需要将这些变量声明为类实例,所以我已经声明如下,
@interface Custom_View : UIView{
boost::asio::io_service io_service_2;
tcp::resolver r_2(io_service_2);
client c_2(io_service_2);
boost::thread* dvr_thread_2;
}
获得错误
Custom_View.h:46:23: Unknown type name 'io_service_2'; did you mean 'boost::asio::io_service'?
Custom_View.h:47:16: Unknown type name 'io_service_2'; did you mean 'boost::asio::io_service'?
Custom_View.h:46:19: Field 'r_2' declared as a function
Custom_View.h:47:12: Field 'c_2' declared as a function
如何解决此错误。
答案 0 :(得分:1)
如果您尝试声明Objective-C类或静态变量,则必须在@interface声明的大括号之外进行。例如(如果你没有声明任何实例变量,可以省略' {}'
@interface SubclassName : SuperclassName
Type variableName;
话虽如此,我对boost库并不熟悉,并且代码中声明的变量似乎不是有效的Objective-C。快速谷歌搜索带来了这个GitHub项目,可能有助于引导您朝着正确的方向前进:https://github.com/mz2/boostoniphone