I am using vscode on archlinux and I need to debug line by line a C code compiled with a makefile.
I have create a task and a launch json which me allow to examine step by step, but I cannot inspect variable throw debug console or through vscode interface.
这是Makefile的摘录
CFLAGS = -Wall -Wextra -Wextra -Wswitch-default -Wswitch-unreachable -Wswitch-bool \
-Wmisleading-indentation -Wnull-dereference -Winit-self -Wstack-protector -Wformat \
-Wformat-security -Wformat-overflow -Wdouble-promotion -Wunused-parameter -Wunused-const-variable \
-Wuninitialized -Wpointer-arith -Wincompatible-pointer-types -Wbad-function-cast \
-Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wlong-long -Og -g -O0\
-Ofast
LDFLAGS = -gdwarf-2 -L/usr/local/lib
.PHONY: clean cleandep mrproper
all: $(EXEC)
myprogram: $(OBJ)
$(CC) -g -o $@ $^ $(LDFLAGS) $(LIBS)
[...]
debug: CFLAGS += -DDEBUG -g
debug: $(EXEC)
关于启动和任务json,它们与我在另一个文件中使用的相同(不使用Makefile进行编译),所以我非常确定.
Basically, when I use the debug console "print <variable>", <variable> is not defined.
I copied this structure How to "fix" debugger in VScode if you have Makefile project on C++? but it used cppdb, which is not supported in archlinux.
更新 我的错误,在Main变量中打印,在Main调用的函数内部,我看不到变量内容(未声明的标识符)