一个宏定义的错误,小弟看不懂,请高手进来看看,有一定的难度
#define PI_SAME(name, type) \
struct name { \
name() { } \
name(type value) { data = value; } \
name(const name & value) { data = value.data; } \
name & operator =(type value) { data = value; return *this; } \
name & operator =(const name & value) { data = value.data; return *this; } \
operator type() const { return data; } \
friend ostream & operator<<(ostream & s, const name & v) { return s << v.data; } \
friend istream & operator>>(istream & s, name & v) { return s >> v.data; } \
private: type data; \
}
#define PI_LOOP(src, dst) \
BYTE *s = ((BYTE *)&src)+sizeof(src); BYTE *d = (BYTE *)&dst; \
while (s != (BYTE *)&src) *d++ = *--s;
#define PI_DIFF(name, type) \
struct name { \
name() { } \
name(type value) { operator=(value); } \
name(const name & value) { data = value.data; } \
name & operator =(type value) { PI_LOOP(value, data); return *this; } \
name & operator =(const name & value) { data = value.data; return *this; } \
operator type() const { type value; PI_LOOP(data, value); return value; }; \
friend ostream & operator<<(ostream & s, const name & value) { return s << (type)value; } \
friend istream & operator>>(istream & s, name & v) { type val; s >> val; v = val; return s; }
private: type data; \
}
#if PBYTE_ORDER==PLITTLE_ENDIAN
PI_SAME(PInt16l, PInt16);
#elif PBYTE_ORDER==PBIG_ENDIAN
PI_DIFF(PInt16l, PInt16);
#endif
本代码来自于H323的开源代码,PWLIB中的,在编译中发现一个错误
--------------------Configuration: Console - Win32 Release-----------------
D:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\xmemory(39) : warning C4100: '_P' : unreferenced formal parameter
D:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\xmemory(41) : warning C4100: '_P' : unreferenced formal parameter
D:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\xlocale(296) : warning C4663: C++ language change: to explicitly specialize class template 'codecvt' use the following syntax:
template<> class codecvt<unsigned short,char,int> ...
D:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\xlocale(387) : warning C4018: '<' : signed/unsigned mismatch
D:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\xlocale(519) : warning C4663: C++ language change: to explicitly specialize class template 'ctype' use the following syntax:
template<> class ctype<char> ...
D:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\xlocale(552) : warning C4100: '_D' : unreferenced formal parameter
D:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\xlocale(554) : warning C4100: '_D' : unreferenced formal parameter
..\..\..\include\ptlib/object.h(2526) : error C2143: syntax error : missing ';' before 'private'
..\..\..\include\ptlib/object.h(2526) : error C2146: syntax error : missing ';' before identifier 'data'
..\..\..\include\ptlib/object.h(2526) : error C2501: 'type' : missing storage-class or type specifiers
..\..\..\include\ptlib/object.h(2526) : fatal error C1004: unexpected end of file found
Error executing cl.exe.
哪个兄弟能帮我解释下这段代码是什么意思,中间有错误,我不知道怎么去修改
小弟不胜感激