Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Preprocessing with g++ and specs-file

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?

like image 986
hermannk Avatar asked Jan 08 '17 17:01

hermannk


People also ask

What is G ++ compiler?

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.

Is G ++ and GCC the same?

DIFFERENCE BETWEEN g++ & gccg++ is used to compile C++ program. gcc is used to compile C program.

Is gcc a linker?

GCC uses a separate linker program (called ld.exe ) to perform the linking.

What is gcc make?

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.


1 Answers

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”.

like image 142
hermannk Avatar answered Sep 30 '22 00:09

hermannk