Tangwx

Tangwx

博客网站

Write stm32 code for configuring code prompt function of C_C++ plugin for offline installation of VScode.

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)

    image-20230615085403173

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
image-20230615085627058

Copy the path of the bin folder, which is D:\MinGW\mingw64\bin in my case

image-20230615085641192

1.3. Configure environment variables#

Right-click on This PC -> Properties -> Advanced system settings -> Environment Variables -> Path

image-20230615085934463

Click on Edit -> New

image-20230615090102117

Paste the path of the bin folder that was copied earlier

image-20230615090159406

Click OK

1.4. Verify MinGW configuration#

Open cmd and enter gcc -v or g++ -v

image-20230615090402128

image-20230615090414764

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

image-20230615090830200

Double-click to enter and find the Download extension in the bottom right corner

image-20230615090924767

Open vscode and go to the Extensions Manager

image-20230615091111672

Click on Install from VSIX and select the extension file we just downloaded

image-20230615091245394

Wait for the import, and you can see that the C/C++ extension installation is complete

image-20230615091222523

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.

image-20230615091613000

Add the header file paths in the project and configure global macro definitions, so that code prompt function can be used without errors

image-20230615110426098

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

image-20230615110937695

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.

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.