c/c++ 头文件引用问题
include <> 引用编译器的类库路径下的头文件
include “” 引用工程目录的相对路径的头文件


include 是编译指令,在编译时,编译器会将相对路径替换成绝对路径,因此,头文件绝对路径=搜索路径+相对路径。

Xcode Build Settings 下 Search Paths设置搜索路径

Header Search Paths:头文件搜索路径设置

$(SRCROOT)宏和$(PROJECT_DIR)宏都指xxx.xcodeproj所在的父目录

例如:引用工程testDemo/scr/test.h 头文件,

Header Search Paths中添加$(SRCROOT),引用为include “scr/test.h"
如果在Header Search Paths中添加$(SRCROOT)/scr,那么头文件引用直接引用 include “test.h”


如果设置了 Always Search User Paths 为 yes,编译器会先搜索User Header Search Paths路径下的目录,在这种情况下include <string.h>,User Header Search Paths 搜索目录下的文件会覆盖系统的头文件

相关文章:

  • 2021-09-29
  • 2021-05-19
  • 2021-07-02
  • 2021-12-07
  • 2022-02-01
猜你喜欢
  • 2021-11-16
  • 2021-08-24
  • 2021-12-20
  • 2021-12-08
  • 2022-12-23
  • 2021-12-03
  • 2022-12-23
相关资源
相似解决方案