【问题标题】:Autoconf: Breaking long lines in stringsAutoconf:打破字符串中的长行
【发布时间】:2018-02-16 22:21:16
【问题描述】:

在我的configure.ac 文件中,我有类似这样的警告和错误:

AC_MSG_ERROR([找不到 Boost Math 头文件,您是否正确指定了 --with-boost-include-path 选项?])

我是老派,喜欢保持行宽小于 80 个字符。但是,当我像这样分割线时(我也喜欢一些适当的缩进)

AC_MSG_ERROR([Could not find the Boost Math header files, did you
 specify the --with-boost-include-path option correctly?])

./configure 打印在屏幕上时,错误消息会保留换行和缩进。

在 Autoconf 中断开字符串的正确方法是什么?

【问题讨论】:

    标签: autoconf


    【解决方案1】:

    这是一个老问题,但我找到了另一个解决方案,你可以像这样使用m4_normalize

    AC_MSG_ERROR(m4_normalize([Could not find the Boost Math header files, did you 
                 specify the --with-boost-include-path option correctly?]))
    

    甚至:

    AC_MSG_ERROR(m4_normalize([
        Could not find the Boost Math header files, did you
        specify the --with-boost-include-path option correctly?
    ]))
    

    【讨论】:

      【解决方案2】:

      为了做这样的事情,定义 M4 宏可能会有所帮助:

      m4_define([bst_e1], [Could not find the Boost Math header files[,] did you])
      m4_define([bst_e2], [specify the --with-boost-include-path option correctly?])
      AC_MSG_ERROR(bst_e1 bst_e2)
      

      您也可以在运行 configure 脚本时执行此操作,因为 AC_MSG_ERROR 将采用变量:

      variable=$(cat | tr '\012' ' ' <<ΕΟF
      Could not find the Boost Math header files, did you
      specify the --with-boost-include-path option correctly?
      ΕΟF
      )
      AC_MSG_ERROR($variable)
      

      【讨论】:

      • 感谢您的建议。但是,我不相信它会使代码更易于阅读,这是我的意图。尽管如此,我会接受你的答案,因为它满足我在问题中提出的要求,即使它似乎有点过于涉及手头的问题。
      【解决方案3】:

      好吧,在阅读了更多内容并尝试了一些东西之后,我似乎可以通过用\ 打破字符串来消除输出中的换行符,但看起来我将无法保留源中的缩进:

      AC_MSG_ERROR([Could not find the Boost Math header files, did you \
      specify the --with-boost-include-path option correctly?])
      

      产生:

      configure: error: Could not find the Boost Math header files, did you specify the --with-boost-include-path option correctly?
      

      AC_MSG_ERROR([Could not find the Boost Math header files, did you \
                    specify the --with-boost-include-path option correctly?])
      

      给予:

      configure: error: Could not find the Boost Math header files, did you        specify the --with-boost-include-path option correctly?
      

      【讨论】:

        猜你喜欢
        • 2013-10-12
        • 2016-11-05
        • 2019-03-19
        • 1970-01-01
        • 2023-03-24
        • 2014-11-14
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多