ACE封装的malloc前面加了两个冒号为什么编译不过
#if !defined (ACE_MALLOC_FUNC)
# define ACE_MALLOC_FUNC ::malloc
namespace ACE_OS
{
extern ACE_Export
void *malloc (size_t);
} /* namespace ACE_OS */
void *
ACE_OS::malloc (size_t nbytes)
{
return ACE_MALLOC_FUNC (nbytes);
}
ACE源码是这样的。。
我模仿了如下的代码
//#include <iostream>
#include <sys/socket.h>
#include <sys/epoll.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
#define TEST_MALLOC_FUNC ::malloc
namespace TEST_OS
{
void *malloc (size_t);
}
void *TEST_OS::malloc (size_t nbytes)
{
return TEST_MALLOC_FUNC (nbytes);
}
int main()
{
TEST::malloc(10);
}
编译的时候报错
In function ‘void* TEST_OS::malloc(size_t)’:
error: ‘::malloc’ has not been declared