【问题标题】:autoheader creates VERSION macro conflicting to other variable defined in other header fileautoheader 创建与其他头文件中定义的其他变量冲突的 VERSION 宏
【发布时间】:2023-04-08 10:07:01
【问题描述】:

我的 configure.ac 文件有如下一行

AC_INIT([myApp], [1.2.3], [dev@company.com])

然后 autoheader/configure 将创建config.in,其中我们将有 2 个宏,如下所示,

/* Define to the version of this package. */
#define PACKAGE_VERSION "1.2.3"

/* Version number of package */
#define VERSION "1.2.3"

我还需要在同一个项目中构建sqlite,并且sqlite头文件还定义了变量VERSION,然后我得到了如下错误

../../config.h:117:17: error: expected unqualified-id before string constant

 #define VERSION "1.2.3"
                 ^ ../../SQLiteCpp/include/SQLiteCpp/Database.h:35:21:note: in expansion of macro ‘VERSION’

 extern const char*  VERSION;        ///< SQLITE_VERSION string from the sqlite3.h used at compile time

每次我都必须手动修改 config.in 以注释掉 VERSION 宏才能让构建继续。我的问题是:

  1. 为什么config.h、PACKAGE_VERSION和VERSION创建的2个宏看起来一样,有什么区别?
  2. 如何解决这个VERSION 宏/变量冲突问题?

谢谢

【问题讨论】:

    标签: macros version conflict autoconf


    【解决方案1】:

    为什么同时使用VERSION 和PACKAGE_VERSION?可能向后兼容。

    如何避免定义VERSION? Automake 信息页面中的 AM_INIT_AUTOMAKE 文档以一段完全处理如何避免 PACKAGE 和 VERSION 成为 AC_DEFINEd 的段落结尾:

    AM_INIT_AUTOMAKE([... no-define ...])
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-04-19
      • 2014-09-23
      相关资源
      最近更新 更多