Offline Installation of C/C++ Plugin Configuration Code Prompt Function for VScode#
1. Install MinGW#
1.1 Download MinGW#
Download from MingW official website
-
Online installation - Download MinGW-W64-install.exe (slow speed)
-
Download compressed package - x86_64-posix-sjlj (fast speed)
1.2. Place the downloaded files in a convenient directory and copy 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. Configure environment variables#
Right-click on This PC -> Properties -> Advanced system settings -> Environment Variables -> Path
Click on Edit -> New
Paste the path of the bin folder that was copied earlier
Click OK
1.4. Verify 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 that the installation was successful
2. Configure C/C++ plugin for 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 and search for C/C++, 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, and you can see that the C/C++ extension installation is complete
3. Configure C/C++ environment#
3.1 Configure 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, so that code prompt function can be used without errors
3.2 Set the file opening format#
Press Ctrl+Shift+P to bring up the command palette, enter settings, and find the Open User Settings feature
Enter encoding and configure the file opening format as GB2312
Now you can happily use VScode to edit code with code prompt function. After writing the code, you can compile, debug, and download it in Keil for convenient development.