XCode包括系统文件而不是本地文件 [英] XCode include system file instead of local file

查看:132
本文介绍了XCode包括系统文件而不是本地文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个iOS项目,并使用



<$ p $在其中一个文件中包含 ifaddrs.h p> #include< ifaddrs.h>最近,我的代码停止了工作(特别是 getifaddrs );



$ c>),我注意到 BLWebSocketsServer 提供了 getifaddrs.h / .c 这似乎导致问题。如果我从XCodes标题和编译源阶段删除这两个文件,我的代码开始工作了。



现在,对于我的问题:


  1. 为什么会发生这种情况? getifaddrs.h 不是< ifaddrs.h> ,所以这应该影响我的代码,应该吗?


  2. 有没有办法在不改变BLWebSocketsServer的情况下解决此问题?


感谢!

解决方案

查看 getifaddrs。[hc] 在BLWebSocketsServer,他们重新定义 getifaddrs ,所以系统实现被覆盖(#include基本上是不相关的)



看起来你可以通过在编译器命令行(或Xcode项目设置中的选项)中定义HAVE_GETIFADDRS = 1来解决这个问题。



定义HAVE_GETIFADDRS在某种程度上等同于从编译阶段删除文件,但是具有额外的好处,BLWebSocketsServer中的其他源不会使用可能无效的getifaddrs相关调用和结构声明。


I am working on an iOS project and include ifaddrs.h in one of my files using

#include <ifaddrs.h>

Recently, my code stopped working (in particular, getifaddrs) and I noticed that BLWebSocketsServer delivers a getifaddrs.h/.c which seems to cause issues. If I remove those two files from XCodes "Headers" and "Compile Sources" phase, my code starts working again.

Now, for my questions:

  1. Why does this happen? getifaddrs.h is not <ifaddrs.h>, so this shouldn'at affect my code, should it?

  2. Is there a way to resolve this without altering BLWebSocketsServer?

Thanks!

解决方案

Looking at getifaddrs.[hc] in BLWebSocketsServer, they are redefining getifaddrs, so the system implementation is being overridden (and the #include is basically irrelevant)

It looks like you can work around that by defining HAVE_GETIFADDRS=1 on your compiler command lines (or in options in the Xcode project settings)

Defining HAVE_GETIFADDRS is somewhat equivalent to removing the files from the compile phase, but has the added benefit that the other sources in BLWebSocketsServer won't be using possibly invalid declarations of getifaddrs related calls and structures.

这篇关于XCode包括系统文件而不是本地文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆