On Wednesday 04 December 2024 14:51:34 LIU Hao wrote:
> 在 2024-12-04 04:17, Pali Rohár 写道:
> > It allowed me to compile application in debug mode with msvcrtd.dll
> > memory leak detector and then run it. It was compiled in the same way
> > via gcc and msvc.
> > 
> > I do not know a better way how to define those functions without locally
> > undefining macros. Is there some gcc/clang extension which can do it in
> > more cleaner way?
> > 
> 
>    #define malloc(s)   _malloc_dbg(s, _NORMAL_BLOCK, __FILE__, __LINE__)
> 
>    /* Put the name in parentheses so it does not invoke the function-like
>     * macro. It's standard behavior; not an extension whatsoever.  */
>    void* __cdecl (malloc) (size_t _Size);
> 

Interesting idea. But it is better than the explicit undefining of
malloc macro? The advantage of pragma solution is that it contains
explicit "#if defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC)" guard which
describe why it is needed. Parenthesis solution around malloc does not
explicitly describe why and when it is needed.


_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to