欢迎使用CSDN-markdown编辑器

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 *’

void pig(char * input);
在 pig("This is a dog!");时会报上述错误
改为  void pig(const char *input);
或者调用时输入 pig((char *)"This is a dog!");

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]];

你可能感兴趣的:(欢迎使用CSDN-markdown编辑器)