Menu

#96 How do I create a C-only (not C++) Cortex-M project?

Version 1.x
closed
None
5
2015-02-07
2015-01-07
No

I noticed that there are project templates for an "ARM C Project" and a "Cortex-M C/C++ Project". I've tried using this template:
https://sourceforge.net/projects/nrf51osx/
…but it's a little out of date, and I'd like to know how to create an nrf51 project myself. When I make a project with the template above, I noticed that it uses GCC for compilation. When I use the Cortex-M C/C++ template, it uses G++. I'd rather use GCC.

Under Project Properties->C/C++ Build->Tool Chain Editor->Used tools, I can click the Select Tools… button, check "Allow all changes", and then remove Cross ARM C++ Compiler and Cross ARM C++ Linker, but the changes don't stick.

How do I just use GCC (not G++) with the Cortex-M0?

Discussion

  • Liviu Ionescu (ilg)

    • status: open --> accepted
    • assigned_to: Liviu Ionescu (ilg)
     
  • Liviu Ionescu (ilg)

    When I use the Cortex-M C/C++ template, it uses G++. I'd rather use GCC.

    all GNU ARM Eclipse templates are C++.

    I'd rather use GCC.

    may I ask you what is the disadvantage of having the projects linked with G++ instead of GCC?

     
  • Peter Watkins

    Peter Watkins - 2015-01-07

    Ah… Well, it's easier to compare a GCC project with its options to the makefiles provided by Nordic. I guess I just wanted to make sure the G++ compiler wasn't putting any object code in that I didn't want.

    I'm still confused about both the C and C++ compiler settings showing up in the "Used Tools" section--it sounds like only the C++ compiler should show up, right?

     
  • Liviu Ionescu (ilg)

    to make sure the G++ compiler wasn't putting any object code in that I didn't want.

    if you have no c++ source files in your project, the c++ compiler is never used.

    the advantage of using g++ as linker is that, even for c projects, you can link a library that has a c interface but internally uses c++ (this is perfectly possible).

    if you have no c++ object files in the project, there is no difference.

    both the C and C++ compiler settings showing up

    nope, c and assembly files are compiled with gcc, c++ files are compiled with g++, each with a separate set of options. both share the common option.

    as long as you do not use c++ files, you don't need to bother with g++ options.

     
  • Peter Watkins

    Peter Watkins - 2015-01-08

    So when I look at the console output, I see that the g++ compiler is called, not gcc. Is g++ just passing all the info on to gcc? Forgive my ignorance of the interactions between g++ and gcc.

     
  • Liviu Ionescu (ilg)

    I see that the g++ compiler is called

    unless you use .cpp files, most probably you see the g++ linker called

    Is g++ just passing all the info on to gcc

    nope. both g++ and gcc are just some kind of wrappers for the actual compiler (cc1) and linker (ld).

    Forgive my ignorance

    in the toolchain install folder you have the GNU original manuals, please read them for more details.

     
  • Liviu Ionescu (ilg)

    • status: accepted --> closed