网站开发能申请软件著作权吗,抖音小程序,小红书推广引流渠道,WordPress门户主题破解VSCode 调试 C 主要就是 .vscode 中的 launch.json 和 tasks.json 的配置。
launch.json 可以通过 vscode 界面 ——》左侧调试功能按钮——》创建 launch.json ——》C#xff08;GDB/LLDB#xff09;生成。
其中 launch.json 默认配置如下#xff0c;主要配置项说明 主要就是 .vscode 中的 launch.json 和 tasks.json 的配置。
launch.json 可以通过 vscode 界面 ——》左侧调试功能按钮——》创建 launch.json ——》CGDB/LLDB生成。
其中 launch.json 默认配置如下主要配置项说明
name启动项的名字program指向最终生成的可执行文件的路径args执行时的输入参数stopAtEntry自动在 main 函数时停止
{version: 0.2.0,configurations: [{name: C/C: g build and debug active file,type: cppdbg,request: launch,program: ${fileDirname}/${fileBasenameNoExtension},args: [],stopAtEntry: false,cwd: ${workspaceFolder},environment: [],externalConsole: false,MIMode: gdb,miDebuggerPath: /usr/bin/gdb,setupCommands: [{description: Enable pretty-printing for gdb,text: -enable-pretty-printing,ignoreFailures: true}],preLaunchTask: C/C: g build active file}]
}
tasks.json 文件可以通过 vscode 菜单 ——》终端——》配置任务 生成。
其中 tasks.json 默认配置如下主要配置项说明
command给出具体编译命令可以是 /usr/bin/g也可以是基于 CMakeLists.txt 直接输入 cmake 命令args编译命令输入参数group.isDefault是否为默认编译方式True 表示默认使用此编译选项
{version: 2.0.0,tasks: [{type: shell,label: C/C: g build active file,command: /usr/bin/g,args: [-g, ${file}, -o, ${fileDirname}/${fileBasenameNoExtension}],options: {cwd: /usr/bin},problemMatcher: [$gcc],group: {kind: build,isDefault: true},detail: Task generated by Debugger.}]
}
CMakeLists.txt 方式
如果使用 CMakeLists.txt需要在 CMakeLists.txt 中添加如下行从而以 Debug 方式一共有以下方式Debug Release RelWithDebInfo 和 MinSizeRel编译。
SET(CMAKE_BUILD_TYPE Debug)
SET(CMAKE_CXX_FLAGS_DEBUG $ENV{CXXFLAGS} -O0 -Wall -g -ggdb)
SET(CMAKE_CXX_FLAGS_RELEASE $ENV{CXXFLAGS} -O3 -Wall)
tasks.json 配置中对应 command 修改如下
{version: 2.0.0,tasks: [{...command: cmake . -B build -DCMAKE_BUILD_TYPEDebug;cmake --build build --target main --config Debug -j,args: [],...]
}