It is currently Mon Apr 06, 2020 9:37 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: [Done] Lists in Structure not aligned with x64
PostPosted: Sat Jan 18, 2020 10:19 am 
Offline
Addict
Addict
User avatar

Joined: Sat Feb 13, 2010 3:45 pm
Posts: 1037
Although it will hardly play a role, Lists in Structures are not aligned in a 64 bit OS. This causes SizeOf to produce a wrong result too.

Code:
Structure MYSTRUC1 Align #PB_Structure_AlignC
  b1.b
  Array MYARRAY.s(3)
  b2.b
EndStructure

Structure MYSTRUC2 Align #PB_Structure_AlignC
  b1.b
  List MYLIST.s()
  b2.b
EndStructure

Structure MYSTRUC3 Align #PB_Structure_AlignC
  b1.b
  Map MYMAP.s(10000)
  b2.b
EndStructure


Debug SizeOf (MYSTRUC1)
Debug SizeOf (MYSTRUC2)
Debug SizeOf (MYSTRUC3)
Debug ""

Debug OffsetOf (MYSTRUC1\b1)
Debug OffsetOf (MYSTRUC1\MYARRAY)
Debug OffsetOf (MYSTRUC1\b2)
Debug ""

Debug OffsetOf (MYSTRUC2\b1)
Debug OffsetOf (MYSTRUC2\MYLIST)
Debug OffsetOf (MYSTRUC2\b2)
Debug ""

Debug OffsetOf (MYSTRUC3\b1)
Debug OffsetOf (MYSTRUC3\MYMAP)
Debug OffsetOf (MYSTRUC3\b2)
Debug ""

_________________
sorry for my bad english


Top
 Profile  
Reply with quote  
 Post subject: Re: Lists in Structure not aligned with x64
PostPosted: Sat Jan 18, 2020 11:31 am 
Offline
Addict
Addict
User avatar

Joined: Fri May 12, 2006 6:51 pm
Posts: 2343
Location: Germany
Confirmed
For 32bit programs it is correct.

_________________
My Projects ThreadToGUI / OOP-BaseClass / OOP-BaseClassDispatch / EventDesigner V3
PB v3.30 / v5.70 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace


Top
 Profile  
Reply with quote  
 Post subject: Re: Lists in Structure not aligned with x64
PostPosted: Sat Jan 18, 2020 12:05 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Feb 13, 2010 3:45 pm
Posts: 1037
What else I noticed. The List-Object consists of two pointers and would therefore have to be aligned to SizeOf(Integer) and not to 2*SizeOf(Integer) as is done with x32.

But this is rather theoretical, since there are no Pb-Lists in C-Structures.

_________________
sorry for my bad english


Top
 Profile  
Reply with quote  
 Post subject: Re: Lists in Structure not aligned with x64
PostPosted: Sun Jan 19, 2020 7:18 am 
Offline
Addict
Addict
User avatar

Joined: Sat Feb 13, 2010 3:45 pm
Posts: 1037
One more thing. I don't know if there are fixed length strings in C/C++. In any case, a FixString is nothing else than an array of characters and should be aligned to SizeOf (Character) in AlignC.

Try this in an unicode exe. The result of 1 does not seem to be correct.
Code:
Structure MYSTRUC Align #PB_Structure_AlignC
  b.b
  s.s{10}
EndStructure

Debug OffsetOf (MYSTRUC\s)

_________________
sorry for my bad english


Top
 Profile  
Reply with quote  
 Post subject: Re: Lists in Structure not aligned with x64
PostPosted: Tue Jan 21, 2020 10:23 am 
Offline
Administrator
Administrator

Joined: Fri May 17, 2002 4:39 pm
Posts: 14016
Location: France
You're right, fixed all the 3 cases


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye