ios开发常见编译告警

gcc编译常见问题解决方法

1、 implicit declaration of function `sleep'

#inlude<unistd.h>

 

2、 implicit declaration of function ‘malloc’

#include<stdlib.h>

3、 implicit declaration of function `memcpy'

#include <string.h>

4、 implicit declaration of function ` inet_addr’

#include <sys/socket.h>

#include <netinet/in.h>

#include <arpa/inet.h>  // 经常是少加了一个文件,然后导致了大量的告警。



5、 suggest parentheses around assignment used as truth value

=改成==

6、 Multiple definition of

将变量声明放到.c


GCC的设定,可以改变GCC编译的代码。

C Language Dialect

GCC_C_LANGUAGE_STANDARD = C89

(C99 permitted if absolutely necessary, especially on iOS)
Choose a standard or non-standard C language dialect.

  • ANSI C:
    Accept ISO C90 and ISO C++, turning off GNU extensions that are incompatible. [-ansi]

    Incompatible GNU extensions include the ‘asm’, ‘inline’, and ‘typeof’ keywords
 (but not the equivalent __asm__, __inline__, and __typeof__ forms), and the ‘//’ syntax for comments.

    This setting also enables trigraphs.
  • C89:
    Accept ISO C90, but not GNU extensions. [-std=c89]
  • GNU89:
    Accept ISO C90 and GNU extensions. [-std=gnu89]
  • C99:
    Accept ISO C99, but not GNU extensions. [-std=c99]
  • GNU99:
    Accept ISO C99 and GNU extensions. [-std=gnu99]
  • Compiler Default:
    Tells the compiler to use its default C language dialect. This is normally the best choice unless you have specific needs. (Currently equivalent to GNU89.)

Please see the full GCC manual for the full definition of all these settings on the C dialect:



ios4.1SDK之后,NSString和char的转换,不推荐使用cString函数了


NSString *str = [NSString alloc]initWithFormat:@“thisis%d”,i];


const char * p_ch = [str UTF8String];


const char * p_ch = [ str cString] ; //对于ios4平台会提示告警。并不再建议使用了。

 

你可能感兴趣的:(ios开发常见编译告警)