In C, is it possible to change exported function name to different one?

前端 未结 3 1271
故里飘歌
故里飘歌 2020-12-17 16:34

all.

I want to link a library which calls malloc() function. However, my target environment is different one and malloc() is supplied as in

3条回答
  •  萌比男神i
    2020-12-17 17:06

    What about:

    #define malloc my_malloc
    #include 
    #undef malloc
    
    int malloc(size_t sz)
    {
       return my_malloc(sz);
    }
    
    #define malloc my_malloc
    // use your malloc here
    

提交回复
热议问题