Preprocessing with g++ and specs-file

692 views Asked by At

The question refers to arm-none-eabi-g++ 6.2 and linking against newlib-nano.

When I preprocess a C-source with -specs=nano.specs, the file newlib.h from the directory newlib-nano is included:

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'

outputs # 1 "/opt/gcc-arm-none-eabi-6_2-2016q4/arm-none-eabi/include/newlib-nano/newlib.h" 1 3 4 (as expected). This is because the file nano.specs contains (among others) the lines

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

But if I feed a C++-source through the same compiler

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'

the output reads # 1 "/opt/gcc-arm-none-eabi-6_2-2016q4/arm-none-eabi/include/newlib.h" 1 3.

In other words: The specs-file is ignored.

I am aware that I should include <cstring> instead of <string.h> in C++ sources and that GNU g++ is commonly invoked by …/arm-none-eabi-c++ instead of …/arm-none-eabi-gcc -x c++ but I did that to carve out the small difference. And: this does not change the matter.

Question: What do I have to add to the specs-file to let C++-files include newlib-nano/newlib.h?

1

There are 1 answers

0
hermannk On

It had been a bug (https://bugs.launchpad.net/gcc-arm-embedded/+bug/1661882). It has been fixed. It will be in the “6-2017-q1-update”.