Thread: packing of a structure form LInux to Windw

  1. #1
    Registered User
    Join Date
    Jul 2009
    Posts
    6

    packing of a structure form LInux to Windw

    Hi all
    I am trying to convert a class fomr linux having the __attribute__((packed)) to Windows.

    I tried to use pragma pack(push,8) and pragma(pop,8) but it doesnt work and I have doubts on that value 8. On whcich base I should use this value?
    Code:
    // from linux
    Class CA{
    } __attribute__((packed)) 
    
    //to  win
    #pragma( push,8 )
    Class CA{
    }#pragma( pop,8 )
    // it doesn't work

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,656
    pragma pack(push,1) would be packed.

    But any packed struct is probably a bug waiting to happen.
    For the most part, it's band-aid on a damaged bit of code, not a solution.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    when I pass data between two unrelated processes, I always encode the data in some form of text based format. XML and JSON are viable options.

  4. #4
    Registered User
    Join Date
    Mar 2009
    Posts
    1
    Thanks..........

    -----------------

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Making an MFC form to suit
    By TJJ in forum Windows Programming
    Replies: 1
    Last Post: 04-17-2004, 11:20 AM
  2. Structure Problem
    By Generator in forum C Programming
    Replies: 5
    Last Post: 07-28-2003, 11:54 PM
  3. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM
  4. Serial Communications in C
    By ExDigit in forum Windows Programming
    Replies: 7
    Last Post: 01-09-2002, 10:52 AM
  5. C structure within structure problem, need help
    By Unregistered in forum C Programming
    Replies: 5
    Last Post: 11-30-2001, 05:48 PM