功能重新定义的问题 [英] function redefined problem
问题描述
在我的项目中,我必须包含一个头文件alloc.h。 malloc()
函数被包装在这个文件中:
alloc.h
#define malloc(a)PROJ_MALLOC (a)
alloc.c
void * PROJ_MALLOC(size_t a){
........ .......
}
因此,每当我使用malloc()时,它实际上将被调用到PROJ_MALLOC。
我的问题是如何使用系统malloc()并避免使用PROJ_MALLOC?
谢谢!
Wei
Hi,
In my project , I has to include a head file "alloc.h". The malloc()
function was wrapped in this file as :
alloc.h
#define malloc(a) PROJ_MALLOC(a)
alloc.c
void *PROJ_MALLOC(size_t a){
.....................
}
So that everytime I use malloc() it will be invoked to PROJ_MALLOC actually.
My question is how can I use system malloc() and avoid using PROJ_MALLOC ?
Thanks!
Wei
推荐答案
Wei Li写道:
Wei Li wrote:
在我的项目中,我必须包含一个头文件alloc .H" ;.
除非您使用的是破坏的实现,否则没有理由将
包含一个名为alloc.h的非标准头文件。对于malloc。 malloc()是标准头文件< stdlib.h>中的
原型。
malloc()
函数被包装在这个文件中:
alloc.h
#define malloc(a)PROJ_MALLOC(a)
alloc.c
void * PROJ_MALLOC(size_t a){
.... ................
所以我每次使用malloc()时都会调用PROJ_MALLOC。
我的问题是如何使用系统malloc()并避免使用PROJ_MALLOC?
Hi,
In my project , I has to include a head file "alloc.h".
Unless you are using a broken implementation, there is no reason to
include a non-standard header named "alloc.h" for malloc. malloc() is
prototyped in the standard header <stdlib.h>.
The malloc()
function was wrapped in this file as :
alloc.h
#define malloc(a) PROJ_MALLOC(a)
alloc.c
void *PROJ_MALLOC(size_t a){
....................
}
So that everytime I use malloc() it will be invoked to PROJ_MALLOC actually.
My question is how can I use system malloc() and avoid using PROJ_MALLOC ?
如果由于某种原因_must_包含非标准标题,
#include" alloc.h"
#if defined(malloc)
#undef malloc
#include< stdlib.h> ;
If you _must_ include that non-standard header for some reason,
#include "alloc.h"
#if defined(malloc)
#undef malloc
#include <stdlib.h>
Wei Li写道:
Wei Li wrote:
在我的项目中,我必须包含一个头文件 ; alloc.h" ;.
除非您使用的是破坏的实现,否则没有理由将
包含一个名为alloc.h的非标准头文件。对于malloc。 malloc()是标准头文件< stdlib.h>中的
原型。
malloc()
函数被包装在这个文件中:
alloc.h
#define malloc(a)PROJ_MALLOC(a)
alloc.c
void * PROJ_MALLOC(size_t a){
.... ................
所以我每次使用malloc()时都会调用PROJ_MALLOC。
我的问题是如何使用系统malloc()并避免使用PROJ_MALLOC?
Hi,
In my project , I has to include a head file "alloc.h".
Unless you are using a broken implementation, there is no reason to
include a non-standard header named "alloc.h" for malloc. malloc() is
prototyped in the standard header <stdlib.h>.
The malloc()
function was wrapped in this file as :
alloc.h
#define malloc(a) PROJ_MALLOC(a)
alloc.c
void *PROJ_MALLOC(size_t a){
....................
}
So that everytime I use malloc() it will be invoked to PROJ_MALLOC actually.
My question is how can I use system malloc() and avoid using PROJ_MALLOC ?
如果由于某种原因_must_包含非标准标题,
#include" alloc.h"
#if defined(malloc)
#undef malloc
#endif
#include< stdlib.h>
If you _must_ include that non-standard header for some reason,
#include "alloc.h"
#if defined(malloc)
#undef malloc
#endif
#include <stdlib.h>
Wei Li写道:
在我的项目中,我必须包含一个头文件alloc.h。
malloc()函数被包装在这个文件中:
In my project , I has to include a head file "alloc.h". The
malloc() function was wrapped in this file as :
错误。相应的头文件是< stdlib.h>
-
Chuck F(cb********@yahoo.com) (cb********@worldnet.att.net)
可用于咨询/临时嵌入式和系统。
< http://cffalconer。 home.att.net>使用worldnet地址!
Wrong. The appropriate header file is <stdlib.h>
--
Chuck F (cb********@yahoo.com) (cb********@worldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address!
这篇关于功能重新定义的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!