Posts

Showing posts from December, 2020

Using C and C++ in projects

See a video demo here: https://youtu.be/OTcDzEyJw8Y A demo project is here: https://github.com/swiftforarduino/community/tree/master/contributed%20examples/Using%20C%20functions.swift4a From Swift for Arduino 4.3 onward, you can add C and C++ files into the build. Either import existing files, drag them into the file list or add new tabs with filenames ending .c or .cpp. You can also include header files for the .c and .cpp files to use. Each file is compiled by AVR GCC. standard avr-gcc for files ending .c and avr-g++ for files ending .cpp. Headers are not automatically imported to swift. To make definitions visible, add a file called main.h (or use the menu option to add a clang import header). This will be used as an import header and definitions will be visible to swift using the clang importer submodule of swift, with the usual restrictions. WORDS OF WARNING: We held back on adding this feature for a long time. It is not a good idea to just drag C or especially C++ files in here t