I know there are slight changes to C++ like C++11 or C++14. If I have a microcontroller or other computer device, what is it that determines if the code can be run on that computer. I.e. what determines if the Arduino can run C++14 code or not?
Is it the compiler on my machine, the interpreter on the other system's processor or what?
It's the compiler's version. If the compiler supports the syntax/C++ version and if the compiler is suitable for the platform - then a valid code will be produced.
@Kiril Kirov's answer is correct, it depends mostly on compiler availability, but some other elements are at stake.
The compiler is responsible for transforming C++ code to machine code in the native instruction set. It also relies on the c++ standard library which obviously needs to be compilable for your system using said compiler. Note that after this operation the produced code is not essentially different from other native code produced by other means (using a C compiler or written by hand), so there's no reason it wouldn't be executed by your microprocessor.
You also need a linker which knows the memory layout of the target microcontroller (processor+RAM+flash memory or ROM).
You also need a way to flash the code to your system, such as USB link and drivers.
In arduino's case, you can find all these elements readily available because it is a known platform (Arduino runs on AVR or ARM depending on the version, so possible compilers would be respectively avr-gcc
or arm-none-eabi-gcc
), but in more exotic cases it isn't a given (chances are that you cannot flash your Mastercard).
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