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
?
g++ command is a GNU c++ compiler invocation command, which is used for preprocessing, compilation, assembly and linking of source code to generate an executable file. The different “options” of g++ command allow us to stop this process at the intermediate stage.
DIFFERENCE BETWEEN g++ & gccg++ is used to compile C++ program. gcc is used to compile C program.
GCC uses a separate linker program (called ld.exe ) to perform the linking.
The GNU Compiler Collection (usually shortened to GCC) is a compiler system produced by the GNU Project supporting various programming languages. make is a "build tool" that invokes the compiler (which could be gcc) in a particular sequence to compile multiple sources and link them together.
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”.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With