Using C++ on Linux in VS Code

这是VS code的官网原文,关于如何使用task.json进行编译C++源文件和debug文件launch.json。

许多博客都有说到这两个文件怎么使用,但是没有详细解说,所以推荐看官网原文,里面还会夹杂一些tips,毕竟官网,新人入门十分推荐。

传送门:https://code.visualstudio.com/docs/cpp/config-linux#_debug-helloworldcpp

注意:官网是英文版的,个人觉得英文版表述会比翻译过来的原汁原味。CET-4阅读起来完全OK,有空后续再追加翻译吧。

VSCode is a popular, open-source code editor that can be used on Linux systems to write and debug code in various programming languages, including C. To use VSCode for C development on Linux, follow these steps: 1. Install VSCode on your Linux system. 2. Install the C/C++ extension for VSCode. This extension provides language support, debugging, and other C-related features in the editor. 3. Create a new C project or open an existing one in VSCode. You can create a new project by using the terminal to navigate to the desired directory and running the command `mkdir project_name && cd project_name && touch main.c`. This will create a new directory with the specified name and an empty C source file named main.c. 4. Write your C code in VSCode. You can use the editor's features, such as syntax highlighting, code completion, and code formatting, to help you write your code. 5. Compile your code using the terminal. You can use the terminal to navigate to your project directory and run the command `gcc -o output_file_name main.c`. This will compile your code and generate an executable file named output_file_name. If there are errors in your code, the compiler will display them in the terminal. 6. Debug your code using the VSCode debugger. You can set breakpoints, step through your code, and inspect variables using the debugger. To use the debugger, you must have compiled your code with debugging symbols by adding the `-g` flag to the `gcc` command when compiling. Overall, VSCode is a powerful and customizable code editor that can be used on Linux for C development. Its features and extensions can make the development process more efficient and enjoyable.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值