I'm trying to replace standard C
functions with my own implementation.
void* malloc(size_t size) {}
void free(void*) {}
gives me the following warnings/errors:
1>main.cpp(26): warning C4273: 'malloc': inconsistent dll linkage
1> C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\corecrt_malloc.h(97): note: see previous definition of 'malloc'
1>main.cpp(31): warning C4273: 'free': inconsistent dll linkage
1> C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\corecrt_malloc.h(85): note: see previous definition of 'free'
1>ucrtd.lib(ucrtbased.dll) : error LNK2005: _free already defined in main.obj
1>ucrtd.lib(ucrtbased.dll) : error LNK2005: _malloc already defined in main.obj
1> Creating library ..\bin\\app.lib and object ..\bin\\app.exp
1>..\bin\\app.exe : fatal error LNK1169: one or more multiply defined symbols found
Is there a way to replace malloc
/free
function in Visual C++ 2015 without using #define
? (I use third party libs and do not want to modify theirs code).