Hello,
I'm not a good programmer; I haven't even managed to install Eclipse. Can I load and compile a C program into the Arduino IDE?
Best regards,
Hans
You have to do it yourself, by default The Arduino IDE injects the main() function for you and thus expects setup() and loop() to be there and will compile using C++ toolchain.
That being said, Yes, you can compile C code in the Arduino IDE by naming your source file with a .c extension.
The Arduino build system will treat .c files as C and compile them with the C compiler (Of course you must avoid any C++ syntax in those files, including Arduino classes like Serial or String).
If you need to call Arduino core functions from your C code, you must include their headers, and make sure they are compatible with C linkage.
If you’re including C functions in a .ino or .cpp file, you may need to wrap the C headers with extern "C" to prevent C++ name mangling.
You can also provide your own main() but then you forfeit all the board’s initialization for the Arduino environment.
Any reason why you wouldn’t go C++ with the IDE ? It’s mostly a superset of C plus the OO constructs so if you know C you can already do a lot.
What is the target platform for the compiled C program ? Are you aiming to produce an executable that would run on a PC, for example, or is the target an Arduino board ?
The target is an STN32F103, BluePill. I'm more of a mechanic; programming is a necessary evil for me. The program isn't mine, but from the internet.
can you share a link to that ?
Not clear to me, is your first target to be able to program that board (STM, not STN anyway) using the Arduino IDE (and therefore using Arduino C language and compiler)?
Anyway, if you need support about STM you must switch to the STM community forums or the Arduino for STM forum.
It’s clearly not meant for the arduino IDE. It’s pretty pointless to want to use it for this.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.