【问题标题】:unknown type name `socklen_t`未知类型名称`socklen_t`
【发布时间】:2012-04-03 14:39:55
【问题描述】:

我安装了 Xcode 4.3.1。尽管SCNetwork.h 中需要包含,但我收到未知类型名称socklen_t 错误

#ifndef _SCNETWORK_H
#define _SCNETWORK_H

#include <Availability.h>
#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/socket.h> // required include
#include <CoreFoundation/CoreFoundation.h>

我是否缺少任何包含?

从终端:

➜  ABC git:(master) ✗ xcodebuild  
=== BUILD NATIVE TARGET ABC OF PROJECT DEF WITH THE DEFAULT CONFIGURATION (Release) ===
Check dependencies
2012-03-19 10:20:43.360 xcodebuild[42278:4403] error: Error Domain=NSPOSIXErrorDomain Code=2 "Non-zero exit code 127 returned from shell command: /usr/bin/gcc-4.2 -v -E -dM -arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk -x objective-c -c /dev/null 2>&1" UserInfo=0x401387be0 {NSLocalizedDescription=Non-zero exit code 127 returned from shell command: /usr/bin/gcc-4.2 -v -E -dM -arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk -x objective-c -c /dev/null 2>&1, NSLocalizedFailureReason=No such file or directory}
2012-03-19 10:20:43.362 xcodebuild[42278:4403] Warning:  Couldn't discover the 'gcc-4.2' compiler's built-in search paths and preprocessor definitions for language dialect 'objective-c'.
Compiler: /usr/bin/gcc-4.2
Reason:   /usr/bin/gcc-4.2 -v -E -dM -arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk -x objective-c -c /dev/null 2>&1
2012-03-19 10:20:43.410 xcodebuild[42278:4403] error: Error Domain=NSPOSIXErrorDomain Code=2 "Non-zero exit code 127 returned from shell command: /usr/bin/gcc-4.2 -v -E -dM -arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk -x c -c /dev/null 2>&1" UserInfo=0x401523f80 {NSLocalizedDescription=Non-zero exit code 127 returned from shell command: /usr/bin/gcc-4.2 -v -E -dM -arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk -x c -c /dev/null 2>&1, NSLocalizedFailureReason=No such file or directory}
2012-03-19 10:20:43.411 xcodebuild[42278:4403] Warning:  Couldn't discover the 'gcc-4.2' compiler's built-in search paths and preprocessor definitions for language dialect 'c'.
Compiler: /usr/bin/gcc-4.2
Reason:   /usr/bin/gcc-4.2 -v -E -dM -arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk -x c -c /dev/null 2>&1
Code Sign error: The identity 'iPhone Distribution' doesn't match any valid, non-expired certificate/private key pair in the default keychain


** BUILD FAILED **


The following build commands failed:
    Check dependencies
(1 failure)

【问题讨论】:

  • &lt;sys/socket.h&gt; 应该包含正确定义socklen_t 的必要标头,因此您的项目或构建配置或其他东西可能有问题。发布预处理器输出(通过 Product → Generate Output → Generate Preprocessed File 菜单选项)。
  • 预处理文件未突出显示。
  • 那又怎样?如果您需要帮助,请发布预处理器输出。
  • 我的意思是,我不能点击它,因为它没有突出显示。还有其他方法可以查看该输出吗?
  • 嗯,这很奇怪。我对 Xcode 4.2 没有任何问题(它的语法也突出了预处理器的输出)。也许尝试退出 Xcode、重新加载和重新预处理?

标签: objective-c ios xcode4 osx-lion xcode4.3


【解决方案1】:

导入SystemConfiguration 框架。

【讨论】:

  • 它在框架文件夹中。 SCNtwork.h 仅在该文件夹中。
  • 你得到 'socklen_t' 没有命名类型吗?
  • 未知类型名称'socklen_t'
  • 看看this
  • 你之前也读过,我在 socket.h 之前有#include &lt;sys/types.h&gt;
猜你喜欢
  • 1970-01-01
  • 2013-04-26
  • 1970-01-01
  • 2014-11-19
  • 2018-10-27
  • 2016-09-16
  • 2017-01-09
  • 2015-01-25
相关资源
最近更新 更多