Using another compiler - are there any merits for general user

Hi

I am currently using the stand-alone Arduino IDE to code for an UNO.

Whilst not a fan of C being a physicist Fortran fanboy I do think the Arduino IDE is a very nice piece of code that makes my newbie life much easier - Brownie points to the coders, thank you!

However ... for a general user is there any merit in using a 3rd party compiler, possibly at the end of development. I believe that gcc can cross-compile for Arduinos. If one ramps up the optimisation level is the resultant code significantly faster/smaller.

More curious than anything else but just wondered if this was a common thing to do.

Thanks

Ian

Read this 10 times to try to understand what you're asking... do you want to compile Arduino sketches and libraries, outside of the Arduino IDE environment? Or invoke a different compiler from within the IDE? Or move to a completely different development environment that supports the more standard C/C++ system of .h .cpp files and makefiles etc?

ianRobinson101:
I believe that gcc can cross-compile for Arduinos.

it certain can. That's what the Arduin IDE uses. look at the tools under Arduino/hardware/tools/avr/bin

_Others ls /tools/Arduino/hardware/tools/avr/bin/
arduinoOTA.exe     avr-gcc-ar.exe      avr-nm.exe       giveio.sys
avr-addr2line.exe  avr-gcc-nm.exe      avr-objcopy.exe  install_giveio.bat
avr-ar.exe         avr-gcc-ranlib.exe  avr-objdump.exe  libiconv-2.dll
avr-as.exe         avr-gcc.exe         avr-ranlib.exe   libusb0.dll
avr-c++.exe        avr-gcov.exe        avr-readelf.exe  loaddrv.exe
avr-c++filt.exe    avr-gdb.exe         avr-run.exe      remove_giveio.bat
avr-cpp.exe        avr-gprof.exe       avr-size.exe     status_giveio.bat
avr-elfedit.exe    avr-ld.bfd.exe      avr-strings.exe
avr-g++.exe        avr-ld.exe          avr-strip.exe
avr-gcc-4.9.2.exe  avr-man             avrdude.exe

Durghh :confused:

thanks for that. I didn't realise that the IDE used gcc

My question appears to have been rather poorly phrased. I was wondering whether there is any merit, for a general user in trying to increase compiler optimisation levels or whether they are already high enough.

Cheers

Ian

By default, code is optimized for size (-Os). See platform.txt.

In some scenarios, -O3 might lead to better performance, but it can also significantly increase memory usage. Given that there's only 32 KiB of flash memory on an UNO, this could be an issue, so -Os is a sensible default.

You can add your own menu options to select the optimization level, that's what Teensy does, for example. (I can't seem to find their boards.txt/platform.txt on GitHub right now, but you can download them from the Teensyduino web page if you're interested how they approach the different optimization levels.)

Pieter

ianRobinson101:
My question appears to have been rather poorly phrased.

i think PieterP is addressing your point about optimization

you're certainly not the only one confused. i've heard arguments that Arduino doesn't use C/C++ because those languages don't have a "byte" variable type. but they are simply typedefs in Arduino.h

typedef bool boolean;
typedef uint8_t byte;

ianRobinson101:
My question appears to have been rather poorly phrased.

It certainly is, but the answer is almost certainly - no. You might ask the question again when you are no longer a general user, and find the standard IDE intolerable.

Thanks very much for your very informed answers. I think I'll leave the settings well alone.

Thanks again

Ian