xcode 编译旧程序遇到的一些问题解决汇总
Posted xiaochunzao
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了xcode 编译旧程序遇到的一些问题解决汇总相关的知识,希望对你有一定的参考价值。
1、Implicit declaration of function 'inet_addr' is invalid in C99
添加 #include <arpa/inet.h>
2、Implicit declaration of function 'read' is invalid in C99
Implicit declaration of function 'write' is invalid in C99
Implicit declaration of function 'close' is invalid in C99
相应的改为 fread,fwrite,fclose,对应函数的参数也要调整
3、Implicit declaration of function 'access' is invalid in C99
添加 #include <unistd.h>
#include <fcntl.h>
4、Implicit declaration of function 'sign_extend' is invalid in C99
在Linux Kernel 的源文件里有定义
static __inline int
sign_extend(int n, int num_bits)
int shift = (int)(sizeof(int) * 8 - num_bits);
return (n << shift) >> shift;
5、Cast from pointer to smaller type 'unsigned int' loses information
替换 为 uintptr_t
6、Implicit conversion loses integer precision: 'long' to 'int'
7、ISO C++11 does not allow conversion from string literal to 'char *<span style="font-family: Arial, Helvetica, sans-serif;">'</span>
<span style="font-family:Arial, Helvetica, sans-serif;">方法一将函数参数声明为 const char *,方法二、字符串前加 (char *)进行显式转换</span>
8、CodeSign error: code signing is required for product type 'OCUnit Test Bundle' in SDK 'ios 8.1'
Edit Scheme 的 build ,去掉 test 的选中
9、网络接口调用失败,提示"NSLocalizedDescription" "unsupported URL"
在URL中如果包含汉字或特殊符号,需要转码到UTF8
NSString *url = @"http://www.testcode.com/test/rest/messReceived?messag=content:name:\\"zhj\\"";
url = [url stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
NSLog(@"url %@",url);
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:url]];
以上是关于xcode 编译旧程序遇到的一些问题解决汇总的主要内容,如果未能解决你的问题,请参考以下文章