The CLion is a cross-platform C/C++ IDE for Linux, OS X, and Windows integrated with the CMake build system. The initial version will support the GCC and Clang compilers and GDB debugger. Clion includes such features as a smart editor, code quality assurance, automated refactorings, project manager, integrated version control systems.
Refer to the CLion Documentation page for more detailed information.
Choose board ID
using platformio boards or Embedded Boards Explorer
command and generate project via platformio init --ide
command:
platformio init --ide clion --board <ID>
# For example, generate project for Arduino UNO
platformio init --ide clion --board uno
Then:
Place source files (*.c, *.cpp, *.h, *.hpp
) to src
directory
Import this project via Menu: File > Import Project
and specify root directory where is located Project Configuration File platformio.ini
Open source file from src
directory
Build project (DO NOT RUN): Menu: Run > Build
.
Warning
See know issue: Arduino .ino files are not supported and how to resolve it.
There are 6 predefined targets for building (NOT FOR RUNNING, see marks on the screenshot below):
PLATFORMIO_BUILD
- Build project without auto-uploading
PLATFORMIO_UPLOAD
- Build and upload (if no errors)
PLATFORMIO_CLEAN
- Clean compiled objects
PLATFORMIO_TEST
- Unit Testing
PLATFORMIO_PROGRAM
- Build and upload using external programmer
(if no errors), see Upload using Programmer
PLATFORMIO_UPLOADFS
- Upload files to file system SPIFFS,
see Uploading files to file system SPIFFS
PLATFORMIO_UPDATE
- Update installed platforms and libraries via platformio update
PLATFORMIO_REBUILD_PROJECT_INDEX
- Rebuild C/C++ Index for the Project.
Allows to fix code completion and code linting issues.
PlatformIO Project Generator created “File Watchers” configuration to monitor
changes in platformio.ini
and automatically rebuild C/C++ Project Index.
You need to install extra plugin named File Watchers
via
“Clion: Preferences > Plugins” to enable this feature.
Warning
The libraries which are added, installed or used in the project
after generating process will not be reflected in IDE. To fix it please run
PLATFORMIO_REBUILD_PROJECT_INDEX
target.
.ino
files are not supported¶CLion uses “CMake” tool for code completion and code linting. As result, it
doesn’t support Arduino files (*.ino
and .pde
) because they are
not valid C/C++ based source files:
Missing includes such as #include <Arduino.h>
Function declarations are omitted.
For example, we have the next Demo.ino
file:
void function setup () {
someFunction(13);
}
void function loop() {
delay(1000);
}
void someFunction(int num) {
}
Let’s convert it to Demo.cpp
:
Add #include <Arduino.h>
at the top of the source file
Declare each custom function (excluding built-in, such as setup
and loop
)
before it will be called.
The final Demo.cpp
:
#include <Arduino.h>
void someFunction(int num);
void function setup () {
someFunction(13);
}
void function loop() {
delay(1000);
}
void someFunction(int num) {
}
Dec 01, 2015 - JetBrains CLion Blog - C++ Annotated: Fall 2015. Arduino Support in CLion using PlatformIO
Nov 22, 2015 - Michał Seroczyński - Using PlatformIO to get started with Arduino in CLion IDE
Nov 09, 2015 - ÁLvaro García Gómez - Programar con Arduino “The good way” (Programming with Arduino “The good way”, Spanish)
See more Articles about us.
Source code of CLion “Blink” Project.