【问题标题】:why do i get error from clang but not with xcode's default compiler when i build the follow code?为什么我在构建以下代码时会从 clang 中得到错误,但在 xcode 的默认编译器中却没有?
【发布时间】:2016-12-01 14:05:06
【问题描述】:
func(char * buff)
{
    if (buff == NULL || buff <= 0)
    {
       //do some things
    }
}

来自 clang 4.0:“指针和零之间的有序比较。”

来自 xcode 8:“构建成功”

i guess this might be the error that could be change to a warning.
What should i do if i want to close this error in clang?

【问题讨论】:

    标签: ios objective-c xcode compiler-errors clang


    【解决方案1】:

    我不知道为什么 Xcode 允许该代码。

    代码本身没有任何意义。指针不是有符号值,因此检查指针是 0 还是负数是没有意义的。

    您可以通过去掉 if 语句的第二部分来修复它。这没有意义。

    顺便说一句,在 Objective-C 代码中使用“func”非常令人困惑。那是 Swift 中函数的标签。起初我无法理解您的代码,因为我看到了 func 并认为它是 Swift,但它没有 Swift 的意义。

    【讨论】:

      猜你喜欢
      • 2014-10-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多