宏可以作为函数名???
D:\Program Files\Microsoft Visual Studio 9.0\VC\crt\src\atox.c
#include <cruntime.h>
#include <mtdll.h>
#include <stdlib.h>
#include <ctype.h>
#include <mbctype.h>
#include <tchar.h>
#include <setlocal.h>
#ifdef _MBCS
#undef _MBCS
#endif /* _MBCS */
#include <tchar.h>
int __cdecl _tstoi(
const _TCHAR *nptr
)
{
return (int)_tstol(nptr);
}
宏做为函数名??
tchar.h 里已经有了一个宏: _tstoi
[解决办法]
我觉得,宏名可以作为函数名。
作为函数名,宏也仅仅是一个替换。
int __cdecl _tstoi(
const _TCHAR *nptr
)
{
return (int)_tstol(nptr);
}
因为在tchar.h里面,_tstoi被定义为一个宏定义(atoi或者wtoi)
那预处理器,在对程序进行预处理时,就把_tstoi替换为atoi。
这和普通的宏替换,没什么区别。
[解决办法]
语法上应该没有问题,我的理解是当存在宏的时候,会优先调用宏,不存在的时候才会调用函数,它们的功能是一致的,感觉函数在此是作为后备的用途。