c++ - Visual Studio 没有正确调试我的程序
问题描述
当我尝试运行简单程序以检查它是否正确编译和调试时,它已编译但在 Visual Studio 代码中它没有正确调试
当我在入口处停止调试并尝试执行步骤时,它没有显示变量并给出了这个错误......
Single stepping until exit from function main,
which has no line number information.
Single stepping until exit from function _fu0___ZSt4cout,
which has no line number information.
Hello
我的程序
#include <iostream>
#include <string>
#include <vector>
int main() {
std::vector<std::string> msg {"Hello", "C++", "World", "from", "VS Code", "and the C++ extension!"};
for(std::string const& i : msg) {
std::cout << i << std::endl;
}
}
和我的launch.json 文件
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug",
"type": "cppdbg",
"request": "launch",
"args": [],
"stopAtEntry": true,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "gdb.exe",
"program": "${workspaceFolder}/bin/main.exe",
"preLaunchTask": "build"
}
]
}
和我的makefile ...
CC := g++
CFLAGS := -std=c++17 -Wall -Wextra -ggdb
BIN := bin
SRC := src
INCLUDE := include
LIB := lib
LIBRARIES :=
ifeq ($(OS),Windows_NT)
EXECUTABLE := main.exe
SOURCEDIRS := $(SRC)
INCLUDEDIRS := $(INCLUDE)
LIBDIRS := $(LIB)
else
EXECUTABLE := main
SOURCEDIRS := $(shell find $(SRC) -type d)
INCLUDEDIRS := $(shell find $(INCLUDE) -type d)
LIBDIRS := $(shell find $(LIB) -type d)
endif
CINCLUDES := $(patsubst %,-I%, $(INCLUDEDIRS:%/=%))
CLIBS := $(patsubst %,-L%, $(LIBDIRS:%/=%))
SOURCES := $(wildcard $(patsubst %,%/*.cpp, $(SOURCEDIRS)))
OBJECTS := $(SOURCES:.cpp=.o)
all: $(BIN)/$(EXECUTABLE)
.PHONY: clean
clean:
-$(RM) $(BIN)/$(EXECUTABLE)
-$(RM) $(OBJECTS)
run: all
./$(BIN)/$(EXECUTABLE)
$(BIN)/$(EXECUTABLE): $(OBJECTS)
$(CC) $(CFLAGS) $(CINCLUDES) $(CLIBS) $^ -o $@ $(LIBRARIES)
什么可能导致调试器的这种行为......
解决方案
推荐阅读
- javascript - 将 JS 中创建的元素移动到 JS 中创建的另一个元素中
- find - 找到 dir xargs rm 输出到 file.log
- python - HTML/CSS 弹出显示列表中的文本
- java - 如何使用 PostgreSQL 错误修复此 Java(表不存在)?
- microsoft-cognitive - LUIS 无法在查询中对多个人名进行分类
- r - 在 R 的循环中创建 xts 列表时会创建额外的列表元素
- node.js - 使用 Node.js 查询连接两个 Postgres 数据库表
- c++ - unique_ptr 和 shared_ptr 的重载方法与多态性不明确
- ssl - ionic 应用服务器设置的 https 设置
- angular - 如何将 dx-data-grid 及其工具包装到另一个组件中并使其成为控制器?