#PB_Structure_AlignC

Just starting out? Need help? Post your questions and find answers here.
PureGuy
Enthusiast
Enthusiast
Posts: 102
Joined: Mon Aug 30, 2010 11:51 am

#PB_Structure_AlignC

Post by PureGuy »

I just noticed the internal ACE_HEADER structure is to small in x64.
So I thought simply use #PB_Structure_AlignC, but it doesn't make a difference.

Shouldn't the #PB_Structure_AlignC make sure that the structure is a multiple of 8 on x64?

Code: Select all

Structure ACE_HEADER_ Align #PB_Structure_AlignC
  AceType.b
  AceFlags.b
  AceSize.w
EndStructure

Debug SizeOf(ACE_HEADER_)
User avatar
Josh
Addict
Addict
Posts: 1183
Joined: Sat Feb 13, 2010 3:45 pm

Re: #PB_Structure_AlignC

Post by Josh »

PureGuy wrote:Shouldn't the #PB_Structure_AlignC make sure that the structure is a multiple of 8 on x64?
No, that's a little bit complexer. There was a comprehensive thread about #PB_Structure_AlignC, but I'm afraid, this thread is moved into the hidden forum for solved Bug-Reports. As far as I know, there are following terms:

- Each item is aligned to a multiple value of its own size
- Stucture unions are aligned to a multiple value of its largest item
- The structure is padded to a multiple value of its largest item

This conditions are the same for 32 and 64 bit. I often use #PB_Structure_AlignC and since some BP-Versions I couldn't locate any problems.

P.S.: If you are not sure, that there is a bug, please use the forum for questions and not the bug-forum.
sorry for my bad english
PureGuy
Enthusiast
Enthusiast
Posts: 102
Joined: Mon Aug 30, 2010 11:51 am

Re: #PB_Structure_AlignC

Post by PureGuy »

Josh wrote: P.S.: If you are not sure, that there is a bug, please use the forum for questions and not the bug-forum.
Actually I'm sure there is at least 1 bug, cause the structure is to small.
According to the help file, there is a second bug, cause #PB_Structure_AlignC doesn't here align like C.
DontTalkToMe
Enthusiast
Enthusiast
Posts: 334
Joined: Mon Feb 04, 2013 5:28 pm

Re: #PB_Structure_AlignC

Post by DontTalkToMe »

PureGuy wrote: Shouldn't the #PB_Structure_AlignC make sure that the structure is a multiple of 8 on x64?
No, why ?
PureGuy wrote: According to the help file, there is a second bug, cause #PB_Structure_AlignC doesn't here align like C.
How did you test this ?

If SizeOf(ACE_HEADER_) is 4 should be ok afaik.

1 + 1 + 2, largest alignment is to 2, structure size must be a multiple of 2.

Code: Select all

	struct MyStruct
	{
		char a;
		char b;	
		short c;
	};

	cout << "sizeof(MyStruct) = " << sizeof(MyStruct) << endl;
Prints 4 on Visual C++ x64.
Fred
Administrator
Administrator
Posts: 16664
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: #PB_Structure_AlignC

Post by Fred »

In C, it align to largest member size, not to 8.
Post Reply