In my experience, neither method is very portable.  What might be best
is a autoconf test to see which one works for the given compiler and
then do some macro magic to handle both conditions???  i.e.

#ifdef PRAGMA_PACK
#pragma pack(1)
#endif

struct foo {
   ... stuff ...
   ... stuff ...
   ... stuff ...
} ATTRIBUTE_PACKING;

#ifdef PRAGMA_PACK
#pragma pack(0)
#endif

??

Al

On Fri, 2008-07-25 at 09:58 -0400, Filion, Stéphane wrote:
> #pragma pack(1)/#pragma pack() fixed this problem
>  
> 
> Did I the first person to see this problem?
>  
> If we want to fix this problem we will need to change a lot file.  I
> "grep" the ipmitool project and I saw 192 occurance of __attribute__
> ((packed))
>  
> Do we want to change all of this structures for #pragma
> pack(1)/#pragma pack()?
>  
>  
> Stéphane Filion, Ing jr. / Jr.
> Eng. 
> Concepteur de logiciel
> Software designer
> [EMAIL PROTECTED] 
> Kontron Canada 
> www.kontron.com
> Tel.: (450) 437-4661 ext: 2459
> Fax: (450) 437-8053
> 
> 
> 
> L'information contenue dans le présent document est la propriété de
> Kontron Canada Inc. et est divulguée en toute confidentialité. Cette
> information ne doit pas être révisée, utilisée, divulguée ou
> distribuée sans le consentement écrit explicite de Kontron Canada Inc.
> Si vous n'êtes pas le destinataire prévu et avez reçu cette
> communication par erreur, veuillez contacter l'originateur et
> supprimer toute copie.
> 
> The information contained in this document is confidential and
> property of Kontron Canada Inc. Any unauthorized review, use,
> disclosure or distribution is prohibited without express written
> consent of Kontron Canada Inc. If you are not the intended recipient,
> please contact the sender and destroy all copies of the original
> message and enclosed attachments.
> 
>         -----Message d'origine-----
>         De : Cress, Andrew R [mailto:[EMAIL PROTECTED]
>         Envoyé : Thursday 24 July 2008 5:20 PM
>         À : Filion, Stéphane; ipmitool-devel@lists.sourceforge.net
>         Objet : RE: [Ipmitool-devel] Ipimitool and GCC 4.3.1
>         
>         
>         Does #pragma pack(1)/#pragma pack()  work for this case with
>         gcc 4.3.1?
>          
>         
>         
>         ______________________________________________________________
>         From: [EMAIL PROTECTED]
>         [mailto:[EMAIL PROTECTED] On
>         Behalf Of Filion, Stéphane
>         Sent: Thursday, July 24, 2008 2:05 PM
>         To: ipmitool-devel@lists.sourceforge.net
>         Subject: [Ipmitool-devel] Ipimitool and GCC 4.3.1
>         
>         
>         
>         I would like to know if somebody already tried to build
>         ipmitool with the GCC >= 4.1?
>          
>         After some investigation, I probably found  a bug with GCC >=
>         4.1  This bug has an impact on the ipmitool.  The bug seems to
>         be related to all packed structure in the ipmitool.  The
>         compiler seems not to pack the structure.
>          
>         
>         With the following example:
>          
>         
> ///////////////////////////////////////////////////////////////////////////////
>         #include <stdio.h>
>          
>         struct  __attribute__ ((packed)) packstruct {
>             unsigned char t0       :5 ;
>             unsigned char t1       :5  ;
>             unsigned char t2       :5 ;
>             unsigned char t3       :5 ;
>             unsigned char t4       :4 ;
>         };
>          
>         int
>         main(int argc, char ** argv)
>         {
>            printf("size: %i\n",sizeof(struct packstruct));
>          
>            if(sizeof(struct packstruct) != 3)
>               return(1);
>            else
>               return(0);
>         }
>         
> //////////////////////////////////////////////////////////////////////////////
>          
>         With this structure, the size of my structure is supposed to
>         be 3 bytes, but with a GCC >= 4.1, the size of my structure is
>         5 bytes.
>          
>          
>          
>         GCC 4.1.2:  Size = 5
>         GCC 4.3.1:  Size = 5
>         GCC 4.0.2:  Size = 3
>         GCC 3.3.6:  Size = 3
>          
>         
>         In other hand, if I use unsigned int instead of unsigned char,
>         the size of the structure is correct.
>          
>         
>         I don't know if I'm wrong or if the IPMITool project will need
>         to take an action?
>          
>         Best regards, 
>          
>         Stephane Filion
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http:// moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________ Ipmitool-devel mailing list 
> Ipmitool-devel@lists.sourceforge.net https:// 
> lists.sourceforge.net/lists/listinfo/ipmitool-devel
-- 
Albert Chu
[EMAIL PROTECTED]
925-422-5311
Computer Scientist
High Performance Systems Division
Lawrence Livermore National Laboratory


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Ipmitool-devel mailing list
Ipmitool-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ipmitool-devel

Reply via email to