当前位置:网站首页>Aiot application innovation competition - get better code completion and jump experience with clion
Aiot application innovation competition - get better code completion and jump experience with clion
2022-06-23 21:15:00 【Yu Hanchen】
background
stay Official website tutorial Some of them NXP RT1062 Of demo engineering , Use the recommended MCUXpresso IDE It's easy to get started after trying , But the only drawback is that the editing function is not powerful enough .
IDE It provides many necessary functions for embedded development , Such as compiling tool chain 、 Code editor 、 The debugger 、 Firmware download tool , But it is weak in the code editor , It is mainly reflected in the inability to complete automatically , That is, input the first few characters of the function , Auto complete function name (IDE Function jump can be realized , However, the auto completion function requires input . Number or :: No. triggers , For embedded c Programming is of little use ).
Usually, the coding is mostly CLion, So consider switching CLion As a code editor (vscode It's fine too , Better code completion requires clangd Support ), Other functions embedded specific functions ( compile 、 debugging ) Official use IDE.
Implementation steps
use MCUXpresso IDE Generate makefile
C/C++ There are currently two popular ways to build projects :make perhaps cmake, In embedded programming, we use make Mainly . When switching editors , There must be makefile To find the header file path 、 Source path 、 Link library path , Then do code analysis to support code jump and completion .
Open sample project , Click build project ,IDE Will generate makefile, As shown in the figure below :
Generate the compiled database
Compiling a database is a json file , The compilation steps and source code path of the project are described in detail , Accurate code completion and jump can be achieved in large projects .make Engineering and cmake Projects can generate compiled databases , And in CLion perhaps vscode Application compilation database .
First installation compiledb Tools
pip3 install compiledb
stay makefile Run the command in the same directory , It will be generated in the current directory compile_commands.json
compiledb -n make
The contents of the compiled database file are as follows :
because makefile The default with
arm-none-eabi-gccTool chain , stay CLion No support method found in , Therefore, it can be replaced bygccTo avoid loading project errors .
use CLion Open the project
Because it's time to makefile Based on the project root directory , So you can copy it directly compile_commands.json To the project root directory , And then use CLion Open the json file , Will prompt open as project, Then you can index all the symbols , And bring more perfect code completion 、 Jump function .
Q&A
Why not CLion You can use makefile
CLion It does support makefile engineering , But does not support MCUXpresso IDE Generated makfile.
Observe MCUXpresso IDE The building process of , Found to be makefile The file in Project root /Debug Under the table of contents , And the directory has only the scripts needed to build , No source code . Use CLion(2021.2 edition ) After opening the project directory , open makefile file , choice load makefile,load Successful but unable to auto jump , The automatic completion function is not complete . Copying the full amount of compiled scripts to the source directory is too heavy , Therefore, consider compiling the database .
边栏推荐
- [redis] intersection and union of ordered sets
- [typescript] some summaries in actual combat
- 【Redis】有序集合的交集与并集
- What if there are too few jetpack compose theme colors? Design your own color system
- Share a super Mary source code
- ASP. Net MVC and asp Net web form
- Whether the offsetwidth includes scroll bars
- Is it safe to open an online securities account or to go to the business department
- Gin security -3: fast implementation of CSRF verification
- Command line add user set password never expires add remote group add administrator group
猜你喜欢

New SQL syntax quick manual!

How PMO uses two dimensions for performance appraisal

How to gradually improve PMO's own ability and management level

Four aspects of PMO Department value assessment

I am 30 years old, no longer young, and have nothing

How does PMO select and train project managers?

What are the main dimensions of PMO performance appraisal?

Steps for formulating the project PMO strategic plan
Application of JDBC in performance test

How to view the role of PMO in agile organizations?
随机推荐
The element of display:none cannot get offsetwidth and offsetHeight
How to define an "enumeration" type in JS
How to process the text of a picture into a table? Can the text in the picture be transferred to the document?
Disaster recovery series (VII) -- hybrid cloud public network export disaster recovery construction
2021 three "myths" of science and technology industry -- yuancosmos, NFT and web 3
Game security - call analysis - write code
How to deal with unclear pictures? How to deal with color balance?
Command line add user set password never expires add remote group add administrator group
JS five methods to judge whether a certain value exists in an array
How to dispose of the words on the picture? How do I add text to a picture?
Initial experience of nodejs express framework
Short video intelligent audit software intelligent audit or manual audit
JS how to get the current local date
[SAP ABAP] call API interface instance
Summary of multiple methods for obtaining the last element of JS array
The substring() method in. JS can be used to intercept all characters after the specified string
Machine learning related
Does the fortress machine need a server? Understand the architectural relationship between fortress machine and server
Do you need a server to set up cloud on demand? What services can cloud on demand provide?
Advantages of token mechanism over cookie mechanism