I was using CRTDBG library to identify memory leaks in visual studio 2019. I need to define "#define _CRTDBG_MAP_ALLOC" macro for getting the line number of the leak occurs. I am unclear that how the macro gets replaced when there is no value to be replaced ??
#define _CRTDBG_MAP_ALLOC
#include <iostream>
#include <crtdbg.h>
using namespace std;
int main()
{
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
int *ptr = (int*)malloc(sizeof(int));
*ptr = 10;
//free(ptr);
return 0;
}
I am a new to c/c++, Kindly help me on this.
Aucun commentaire:
Enregistrer un commentaire