首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >VsCode crtdbg.h未找到,如何修复?

VsCode crtdbg.h未找到,如何修复?
EN

Stack Overflow用户
提问于 2019-03-05 22:57:45
回答 1查看 4.7K关注 0票数 3

试图检查内存泄漏工具,但是Vscode不识别#include <crtdbg.h>

以下是代码:

代码语言:javascript
复制
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
#include <stdio.h>
#include <string.h>

int main()
{
    char *word = "this still relevant.";
    char *mem = (char *)malloc(sizeof(word));
    strcpy(mem, word);
    printf("%s", mem);
    system("pause");
    _CrtDumpMemoryLeaks();
}

编译错误:

代码语言:javascript
复制
source.c:4:10: fatal error: crtdbg.h: No such file or directory
#include <crtdbg.h>

如何正确地包含crtdbg.h?

PS:我使用的是MinGW编译器,除了它什么都能工作。

编辑1:另一个帖子的解决方案不起作用。如果我使用建议的代码,就会出现这种情况。

代码语言:javascript
复制
source.c:24:5: error: '_CrtDumpMemoryLeaks' was not declared in this scope
     _CrtDumpMemoryLeaks();

编辑2:有人使用VsCode和MinGW吗?

EN

回答 1

Stack Overflow用户

发布于 2020-11-17 14:43:15

我认为VSCODE无法访问头文件、crtdbg.h、Pease,这是一种简单的方法。也许它解决了你的问题:

1-作为管理员开发人员命令提示运行VS2019。我强调以管理员身份运行,而不是运行。

2-类型代码。

3-打开项目文件夹。

4-快乐的编码和享受它。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55012944

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档