【问题标题】:Preprocessing with g++ and specs-file使用 g++ 和规范文件进行预处理
【发布时间】:2017-01-08 17:48:04
【问题描述】:

问题是指 arm-none-eabi-g++ 6.2 并链接到 newlib-nano。

当我使用-specs=nano.specs 预处理C 源代码 时,包含newlib-nano 目录中的文件newlib.h

echo '#include <string.h>' |\
/opt/gcc-arm-none-eabi-6_2-2016q4/bin/arm-none-eabi-gcc -specs=nano.specs -x c -E - |\
grep '^# 1 .*newlib\.h'

输出# 1 "/opt/gcc-arm-none-eabi-6_2-2016q4/arm-none-eabi/include/newlib-nano/newlib.h" 1 3 4(如预期的那样)。这是因为文件nano.specs 包含(除其他外)这些行

%rename cpp     nano_cpp
 
*cpp:
-isystem =/include/newlib-nano %(nano_cpp)

但如果我通过同一个编译器提供 C++-source

echo '#include <string.h>' |\
/opt/gcc-arm-none-eabi-6_2-2016q4/bin/arm-none-eabi-gcc -specs=nano.specs -x c++ -E - |\
grep '^# 1 .*newlib\.h'

输出为# 1 "/opt/gcc-arm-none-eabi-6_2-2016q4/arm-none-eabi/include/newlib.h" 1 3

换句话说:specs 文件被忽略。

我知道我应该在 C++ 源代码中包含 &lt;cstring&gt; 而不是 &lt;string.h&gt;,并且 GNU g++ 通常由 …/arm-none-eabi-c++ 而不是 …/arm-none-eabi-gcc -x c++ 调用,但我这样做是为了切出 small 区别。并且:这并没有改变问题。

问题:我必须在 specs 文件中添加什么才能让 C++ 文件包含 newlib-nano/newlib.h

【问题讨论】:

    标签: c++ c gcc c-preprocessor newlib


    【解决方案1】:

    这是一个错误 (https://bugs.launchpad.net/gcc-arm-embedded/+bug/1661882)。它已被修复。它将在“6-2017-q1-update”中。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-01-20
      • 1970-01-01
      • 2020-01-07
      • 1970-01-01
      • 2015-09-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多