开发者

error: 'AcceptCallback' undeclared

开发者 https://www.devze.com 2022-12-27 15:40 出处:网络
I\'m trying to create a TCP server for iPhone. I am following an example Journal of the iPhone to help \"SimpleNetworkStream\".

I'm trying to create a TCP server for iPhone. I am following an example Journal of the iPhone to help "SimpleNetworkStream". At compile time I get an error "error: 'Ac开发者_JS百科ceptCallback' undeclared (first use in this function). Could someone help me understand why all of this. The statement seems identical to that made by the example Journal. Thanks

self.listeningSocket = CFSocketCreateWithNative(
              NULL,
              fd,
              kCFSocketAcceptCallBack,
              AcceptCallback,
              &context
              );



    static void AcceptCallback(CFSocketRef s, CFSocketCallBackType type, CFDataRef address, const void *data, void *info)

    {
    //code
    }


Add a forward declaration.

static void AcceptCallback(CFSocketRef s, CFSocketCallBackType type, CFDataRef address, const void *data, void *info);
...
self.listeningSocket = CFSocketCreateWithNative( ... );
...
static void AcceptCallback(...) {
  ...

Or just put the whole definition of AcceptCallback before that assignment.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号