I noticed that a lot of SDK header files don't have " #pragma pack() " statements. For example:
SDK:Include/include_h/libraries/ahi_sub.h
SDK:Include/include_h/libraries/application.h
SDK:Include/include_h/libraries/blankermodule.h
SDK:Include/include_h/libraries/bzip2.h
SDK:Include/include_h/libraries/docky.h
SDK:Include/include_h/libraries/filesysbox.h
SDK:Include/include_h/libraries/screenblanker.h
SDK:Include/include_h/libraries/z.h
Can I assume that we don't need the " #pragma pack() " stuff in our includes any more? If not, then a lot of SDK header files (more than the above examples) need to be updated.
Are #pragma pack() statements no longer needed?
Are #pragma pack() statements no longer needed?
AmigaOne X1000 with 2GB memory - OS4.1 FE
- broadblues
- AmigaOS Core Developer
- Posts: 600
- Joined: Sat Jun 18, 2011 2:40 am
- Location: Portsmouth, UK
- Contact:
Re: Are #pragma pack() statements no longer needed?
That would be a poor assumption.
Just because one header doesn't have them doesn't mean you can omit them from one that does.
During my early work on PPaint there were some coppies of system structures for forward compatabilty (at the time PPAint was originally written), being 68k SASC based code there was no pragma pack statements around those, so they didn't align correctly when compiled with gcc, giving odd crashes that took a bit of head scratching to fix until I realised and added the pragmas.
All those includes you mention are recent, post PPC includes, so no need for the pragma pack, as native alignment will be correct.
Just because one header doesn't have them doesn't mean you can omit them from one that does.
During my early work on PPaint there were some coppies of system structures for forward compatabilty (at the time PPAint was originally written), being 68k SASC based code there was no pragma pack statements around those, so they didn't align correctly when compiled with gcc, giving odd crashes that took a bit of head scratching to fix until I realised and added the pragmas.
All those includes you mention are recent, post PPC includes, so no need for the pragma pack, as native alignment will be correct.
Re: Are #pragma pack() statements no longer needed?
I've been putting "#pragma pack()" statements in my headers since I started programming with OS4.x but when I noticed that some SDK headers don't have them, I was just wondering if I could stop using them in my programs.broadblues wrote:That would be a poor assumption.
Just because one header doesn't have them doesn't mean you can omit them from one that does.
During my early work on PPaint there were some coppies of system structures for forward compatabilty (at the time PPAint was originally written), being 68k SASC based code there was no pragma pack statements around those, so they didn't align correctly when compiled with gcc, giving odd crashes that took a bit of head scratching to fix until I realised and added the pragmas.
All those includes you mention are recent, post PPC includes, so no need for the pragma pack, as native alignment will be correct.
AmigaOne X1000 with 2GB memory - OS4.1 FE
- broadblues
- AmigaOS Core Developer
- Posts: 600
- Joined: Sat Jun 18, 2011 2:40 am
- Location: Portsmouth, UK
- Contact:
Re: Are #pragma pack() statements no longer needed?
There no reason at all, nor, I think, has there ever been, to put them in a programs private headers, assuming all parts of that program are compiled under OS4.
You *might* need them if that OS4 prgram can have 68k pugins / libs or vice verca and those plugins share data via a structure.
You might also need them if you write data to disk as a raw structure and then that data might be read back by a 68k app, or any context where the alignment might not be guarenteed.
You *might* need them if that OS4 prgram can have 68k pugins / libs or vice verca and those plugins share data via a structure.
You might also need them if you write data to disk as a raw structure and then that data might be read back by a 68k app, or any context where the alignment might not be guarenteed.
- salass00
- AmigaOS Core Developer
- Posts: 530
- Joined: Sat Jun 18, 2011 3:12 pm
- Location: Finland
- Contact:
Re: Are #pragma pack() statements no longer needed?
@xenic
The latest AHI includes in the AmigaOS source repo do now have the standard alignment pragma statements (also optional AmigaOS namespace for C++). Most likely they were left out before because no-one thought to add them and the lack of them didn't cause any problems because none of the public AHI structures have non-aligned long words or pointers.
The latest AHI includes in the AmigaOS source repo do now have the standard alignment pragma statements (also optional AmigaOS namespace for C++). Most likely they were left out before because no-one thought to add them and the lack of them didn't cause any problems because none of the public AHI structures have non-aligned long words or pointers.