packing of a structure form LInux to Windw

This is a discussion on packing of a structure form LInux to Windw within the C++ Programming forums, part of the General Programming Boards category; Hi all I am trying to convert a class fomr linux having the __attribute__((packed)) to Windows. I tried to use ...

  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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,417
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Oct 2006
    Posts
    2,266
    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, 09:52 AM
  5. C structure within structure problem, need help
    By Unregistered in forum C Programming
    Replies: 5
    Last Post: 11-30-2001, 04:48 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21