Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

在linux平台下add_cincludes出現的問題 #348

Closed
orzuk-lmj opened this issue Feb 11, 2019 · 3 comments
Closed

在linux平台下add_cincludes出現的問題 #348

orzuk-lmj opened this issue Feb 11, 2019 · 3 comments
Milestone

Comments

@orzuk-lmj
Copy link
Contributor

orzuk-lmj commented Feb 11, 2019

貌似顯示的訊息有些怪。

option("check_sys_types_h")
    add_cincludes("sys/types.h")
    set_configvar("HAVE_SYS_TYPES_H", 1)

option("check_off64_t")
    add_cincludes("sys/types.h")
    add_ctypes("off64_t")
    set_configvar("HAVE_OFF64_T", 1)

輸出的結果為:

checking for the c++ includes(sys/types.h) ... no
checking for the c++ types(off64_t) ... no
checking for the check_off64_t ... no

checking for the c++ includes(sys/types.h) ... ok
checking for the check_sys_types_h ... ok
  • 奇怪的點在於同樣是 sys/types.h 為什麼一個是成功,另一個失敗?
  • 補充一下,更新前用的是 add_defines_h("HAVE_SYS_TYPES_H") 這種舊版設置
@orzuk-lmj
Copy link
Contributor Author

orzuk-lmj commented Feb 11, 2019

另外一個類似的問題是,若我想 add_cincludes 檢查之前先 define _GNU_SOURCE=1 的話,那麼我該如何設置?

@waruqi
Copy link
Member

waruqi commented Feb 12, 2019

奇怪的點在於同樣是 sys/types.h 為什麼一個是成功,另一個失敗?

这个只是输出显示信息误导了,每个option只检测一次,check(sys/types.h + off64_t) 算一次完整检测,里面off64_t检测失败了,导致整个option失败,后面的 ... no都是显示同一个option的检测结果。。

我刚更新了下dev,改进了下输出提示,避免误导用户。

> checking for the c++ includes(sys/types.h)
> checking for the c++ types(off64_t)
checking for the check_off64_t ... no

关于为何会检测失败,这个就要看-D提供的完整检测信息了:

checkinfo: /Users/ruki/.local/share/xmake/core/base/os.lua:705: /Users/ruki/.local/share/xmake/core/base/os.lua:705: /Users/ruki/.local/share/xmake/core/base/os.lua:705: /tmp/.xmake501/190212/_7EFB32517D4B25213B8FC12F73D88186.c:4:9: error: unknown type name 'off64_t'; did you mean 'off_t'?
typedef off64_t __type_off___t;
        ^~~~~~~
        off_t

補充一下,更新前用的是 add_defines_h("HAVE_SYS_TYPES_H") 這種舊版設置

跟这个没啥关系

另外一個類似的問題是,若我想 add_cincludes 檢查之前先 define _GNU_SOURCE=1 的話,那麼我該如何設置?

直接添加个 add_defines("_GNU_SOURCE=1")到option就行了

option("check_off64_t")
    add_cincludes("sys/types.h")
    add_ctypes("off64_t")
    add_defines("_GNU_SOURCE=1")
    set_configvar("HAVE_OFF64_T", 1)

@waruqi
Copy link
Member

waruqi commented Feb 12, 2019

另外你可以用新dev版本提供的内置辅助函数, includes("check_xxxx.lua")去检测,效果完全等价于上面的设置

includes("check_ctypes.lua")
includes("check_cincludes.lua")

target("test")
    set_kind("binary")
    add_files("src/*.c") 

    add_configfiles("config.h.in")

    configvar_check_cincludes("HAVE_SYS_TYPES_H", "sys/types.h")
    configvar_check_ctypes("HAVE_OFF64_T", "off64_t", {includes = "sys/types.h", defines = "_GNU_SOURCE=1"})

关于这块的更多信息,见:#342

@waruqi waruqi added this to the v2.2.5 milestone Feb 12, 2019
@waruqi waruqi closed this as completed Feb 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants