Configuring Code Prompt Function for Writing STM32 Code with Offline Installation of C/C++ Plugin in VScode#
1. Installing MinGW#
1.1 Downloading MinGW#
Download MinGW from the official website
-
Online Installation - Download MinGW-W64-install.exe (slow speed)
-
Downloading Compressed Package - ×86_64-posix-sjlj (fast speed)
1.2. Placing the Downloaded Files in a Convenient Directory and Copying the Path of the bin Directory#
Here, I extracted the compressed package to the D:\MinGW\mingw64
folder.
Copy the path of the bin folder, which is D:\MinGW\mingw64\bin
in my case.
1.3. Configuring Environment Variables#
Right-click on "This PC" -> Properties -> Advanced system settings -> Environment Variables -> Path
Click on Edit -> New
Paste the copied path of the bin folder
Click OK
1.4. Verifying MinGW Configuration#
Open cmd and enter gcc -v
or g++ -v
You can see that the versions of gcc and g++ are both 8.1.0, indicating a successful installation.
2. Configuring C/C++ Plugin in VScode#
Since the computer with VScode installed does not have internet access, I will use the offline installation method to install the C/C++ plugin.
Go to Visual Studio Marketplace VScode Extensions, search for C/C++, and select the first one.
Double-click to enter and find the Download Extension in the bottom right corner.
Open VScode and go to the Extensions Manager.
Click on "Install from VSIX" and select the extension file we just downloaded.
Wait for the import to finish, and you can see that the C/C++ extension installation is completed.
3. Configuring C/C++ Environment#
3.1 Configuring the Compiler#
Next, configure the compiler path. Press Ctrl+Shift+P to bring up the command palette, enter C/C++, and select "Edit Configurations(UI)" to enter the configuration.
Add the header file paths in the project and configure global macro definitions. This way, you can use the code prompt function without errors.
3.2 Setting the File Opening Format#
Press Ctrl+Shift+P to bring up the command palette, enter settings, and find "Open User Settings" function.
Enter encoding and configure the file opening format as GB2312.
Now you can happily use VScode to edit code with the code prompt function. After writing the code, you can compile, debug, and download it in Keil for convenient development.