1

I have an arduino board (SAMD21 microcontroller) which supports either Arduino or CircuitPython programming. I'd like to program in pure C/C++ instead of Arduino, which seems to be possible without too much trouble. But I'm not sure whether to use C or C++. I thought Arduino was based in C++ but I went to look at some of the library files and they were written in C. Since I'm pretty sure they're not interchangeable, can someone help me learn which language I should use to program my board?

2
  • 1
    Whichever you are most comfortable in. C is a subset of C++ (or the other way around - C++ is a superset of C).
    – Majenko
    Nov 21 '21 at 22:57
  • You can effectively use either c or c++ in Arduino. There's a few caveats to be aware of, but they both work. You can even inline assembly if you want.
    – dandavis
    Nov 22 '21 at 10:49
3

I thought Arduino was based in C++

There is no language "Arduino" - the Arduino IDE runs a the GNU C++ compiler so "its language" is the language supported by the compiler. It is primarily C++ with a little bit of preprocessing done to your code to help learners get past some of the places they can trip over easily (adding #include statements when it thinks you need them, for instance).

Here is an answer I wrote to a similar question a few years ago. I think it's relevant to your question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.