当前位置: 技术问答>linux和unix
关于gcc下使用namespace的问题
来源: 互联网 发布时间:2015-07-12
本文导语: 我使用g++编译一个程序 程序是这么写的: ---------strutility.h----------- #ifndef STRUTILITY_H #define STRUTILITY_H namespace iceStr { char *strcpy(char *dest, const char *src); char *strcat(char *dest, const char *src); } #endif --------...
我使用g++编译一个程序 程序是这么写的:
---------strutility.h-----------
#ifndef STRUTILITY_H
#define STRUTILITY_H
namespace iceStr
{
char *strcpy(char *dest, const char *src);
char *strcat(char *dest, const char *src);
}
#endif
---------------------------------
---------strutility.cpp---------
#include "strutility.h"
char *iceStr::strcpy(char *dest, const char *src)
{
...
}
char *iceStr::strcat(char *dest, const char *src)
{
...
}
--------------------------------
我使用 如下指令 编译
g++ -c strutility.cpp
结果出现如下警告:
struility.cpp: In function `char *iceStr::strcpy (char *, const char
*)':
struility.cpp:10: warning: new declaration `char *iceStr::strcpy (char
*, const char *)'
struility.cpp:10: warning: ambiguates built-in declaration `char
*strcpy (char *, const char *)'
请问 这是怎么回事? 我该怎么办?
---------strutility.h-----------
#ifndef STRUTILITY_H
#define STRUTILITY_H
namespace iceStr
{
char *strcpy(char *dest, const char *src);
char *strcat(char *dest, const char *src);
}
#endif
---------------------------------
---------strutility.cpp---------
#include "strutility.h"
char *iceStr::strcpy(char *dest, const char *src)
{
...
}
char *iceStr::strcat(char *dest, const char *src)
{
...
}
--------------------------------
我使用 如下指令 编译
g++ -c strutility.cpp
结果出现如下警告:
struility.cpp: In function `char *iceStr::strcpy (char *, const char
*)':
struility.cpp:10: warning: new declaration `char *iceStr::strcpy (char
*, const char *)'
struility.cpp:10: warning: ambiguates built-in declaration `char
*strcpy (char *, const char *)'
请问 这是怎么回事? 我该怎么办?
|
---------strutility.cpp---------
#include "strutility.h"
namespace iceStr
{
char *iceStr::strcpy(char *dest, const char *src)
{
...
}
char *iceStr::strcat(char *dest, const char *src)
{
...
}
}
--------------------------------
#include "strutility.h"
namespace iceStr
{
char *iceStr::strcpy(char *dest, const char *src)
{
...
}
char *iceStr::strcat(char *dest, const char *src)
{
...
}
}
--------------------------------