搞不定offsetof警告,改用指针,屏蔽sizeof隐式截断
This commit is contained in:
parent
c6bfa47be5
commit
ef3dfcbda1
|
@ -177,8 +177,11 @@ typedef struct _TCP_HEADER
|
||||||
|
|
||||||
void Init(bool recursion = false)
|
void Init(bool recursion = false)
|
||||||
{
|
{
|
||||||
|
#pragma GCC diagnostic ignored "-Woverflow"
|
||||||
Length = (byte)sizeof(this[0]);
|
Length = (byte)sizeof(this[0]);
|
||||||
//Length = (byte)0x14;
|
//Length = (byte)0x14;
|
||||||
|
#pragma GCC diagnostic warning "-Woverflow"
|
||||||
|
|
||||||
reserved_1 = 0;
|
reserved_1 = 0;
|
||||||
reserved_2 = 0;
|
reserved_2 = 0;
|
||||||
//WindowSize = _REV16(8192);
|
//WindowSize = _REV16(8192);
|
||||||
|
|
|
@ -43,7 +43,10 @@ void Device::Write(Stream& ms) const
|
||||||
{
|
{
|
||||||
TS("Device::Write");
|
TS("Device::Write");
|
||||||
|
|
||||||
|
/*#pragma GCC diagnostic ignored "-Winvalid-offsetof"
|
||||||
Buffer bs((void*)&Address, offsetof(Device, Cfg) - offsetof(Device, Address));
|
Buffer bs((void*)&Address, offsetof(Device, Cfg) - offsetof(Device, Address));
|
||||||
|
#pragma GCC diagnostic warning "-Winvalid-offsetof"*/
|
||||||
|
Buffer bs((void*)&Address, (byte*)&Cfg - (byte*)&Address);
|
||||||
ms.WriteArray(bs);
|
ms.WriteArray(bs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +55,8 @@ void Device::Read(Stream& ms)
|
||||||
TS("Device::Read");
|
TS("Device::Read");
|
||||||
|
|
||||||
// 为了避免不同版本的配置兼容,指定长度避免覆盖过头
|
// 为了避免不同版本的配置兼容,指定长度避免覆盖过头
|
||||||
Buffer bs(&Address, offsetof(Device, Cfg) - offsetof(Device, Address));
|
//Buffer bs(&Address, offsetof(Device, Cfg) - offsetof(Device, Address));
|
||||||
|
Buffer bs(&Address, (byte*)&Cfg - (byte*)&Address);
|
||||||
//bs = ms.ReadArray();
|
//bs = ms.ReadArray();
|
||||||
// 为了减少一个临时对象,直接传入外部包装给内部拷贝
|
// 为了减少一个临时对象,直接传入外部包装给内部拷贝
|
||||||
uint len = ms.ReadEncodeInt();
|
uint len = ms.ReadEncodeInt();
|
||||||
|
|
|
@ -538,8 +538,9 @@ TokenStat::TokenStat()
|
||||||
_Last = nullptr;
|
_Last = nullptr;
|
||||||
_Total = nullptr;*/
|
_Total = nullptr;*/
|
||||||
|
|
||||||
int start = offsetof(TokenStat, SendRequest);
|
/*int start = offsetof(TokenStat, SendRequest);
|
||||||
Buffer((byte*)this + start, sizeof(TokenStat) - start).Clear();
|
Buffer((byte*)this + start, sizeof(TokenStat) - start).Clear();*/
|
||||||
|
Buffer(&SendRequest, (byte*)&WriteReply + sizeof(WriteReply) - (byte*)&SendRequest).Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
TokenStat::~TokenStat()
|
TokenStat::~TokenStat()
|
||||||
|
|
|
@ -693,7 +693,7 @@ namespace NewLife.Reflection
|
||||||
|
|
||||||
private String GetObjPath(String file)
|
private String GetObjPath(String file)
|
||||||
{
|
{
|
||||||
var objName = "Obj";
|
var objName = "Gcc";
|
||||||
if (Tiny)
|
if (Tiny)
|
||||||
objName += "T";
|
objName += "T";
|
||||||
else if (Debug)
|
else if (Debug)
|
||||||
|
|
Loading…
Reference in New Issue