【问题标题】:Bundling getopt_long() with my own code?将 getopt_long() 与我自己的代码捆绑在一起?
【发布时间】:2015-07-10 22:45:57
【问题描述】:

我在 github 上有自己的 C 项目。我想通过使用 GNU getopt_long()(它有自己的 git 存储库)来添加长选项支持。我相信有 4 种方法可以做到这一点:

  1. 使用git submodule
  2. 使用git subtree
  3. 将当前 (2.22.6) 快照的源代码导入我自己的 git 存储库。
  4. 仅导入getopt.cgetopt1.cgnugetopt.hgetopt_long() 源文件。

1 和 2 的优点是我跟踪 getopt_long()。 3 和 4 的优点是,如果 getopt_long() 的 git 存储库移动,它不会破坏我的存储库并且这样做更简单。

是否有推荐的“GNU 方式”来执行此操作?

【问题讨论】:

  • 为什么完全导入源而不使用库?
  • 因为它不是在所有平台上。

标签: c getopt getopt-long


【解决方案1】:

再谷歌搜索后,我找到了the official GNU answer

简而言之,有两种推荐的方法:

使用 Gnulib(“新”方式)

使用gnulib-tool 命令,通过对configure.acMakefile.am 文件进行一些调整,导入getopt 以将其编译为GNU 库的子集。

使用getopt_long 来源(“旧”方式)

导入getopt.cgetopt1.cgnugetopt.hgetopt_long源,并使用adl_func_getopt_long.m4宏测试平台上是否存在getopt_long,仅在必要时编译导入的源。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-11-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-25
    • 2014-01-26
    • 2023-03-27
    相关资源
    最近更新 更多