Thread: Urgent Help On pragma packed

  1. #1
    Registered User
    Join Date
    Dec 2002
    Posts
    103

    Urgent Help On pragma packed

    Hi Guys,

    I need to have a tightly packed structure. I believe I need to use pragma packed to achieve the same.

    How do I go about using it and what are the related env variables I need to set??????

    Help needed as early as possible.... and as detailed as possible...

    I am working on Sun Solaris and use CC to compile.
    Have a wonderful day.... and keep smiling... you look terrific that way
    signing off...
    shiv... as i know him

  2. #2
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Example:

    Code:
    #pragma pack(push,1)
    struct Byte 
    {
     unsigned int b0 : 1;
     unsigned int b1 : 1;
     unsigned int b2 : 1;
     unsigned int b3 : 1;
     unsigned int b4 : 1;
     unsigned int b5 : 1;
     unsigned int b6 : 1;
     unsigned int b7 : 1;
    };
    #pragma pack(pop)
    In this case, sizeof(struct Byte) would/should return 1.
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  3. #3
    Registered User
    Join Date
    Dec 2002
    Posts
    103

    Thanks Buddy....

    The information you provided was very helpful....
    Have a wonderful day.... and keep smiling... you look terrific that way
    signing off...
    shiv... as i know him

  4. #4
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    Posts
    1,916
    Oh my gosh this is so urgent! It is more important than anything else anyone has to say on the board! It's urgent, and I need help! Help me now, please! Hurry! There isn't much time! Especially not enough time to notice that the board rules

    Don't put urgent in the title.
    Away.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. labels inside the code #pragma mark label
    By nacho4d in forum C++ Programming
    Replies: 6
    Last Post: 01-11-2009, 02:50 AM
  2. Programming a PIC 16F84 microcontroller in C
    By Iahim in forum C Programming
    Replies: 1
    Last Post: 05-13-2004, 02:23 PM
  3. what does #pragma do?
    By cbc in forum C++ Programming
    Replies: 2
    Last Post: 10-16-2003, 06:51 AM
  4. what is a pragma comment?
    By Shadow12345 in forum C++ Programming
    Replies: 9
    Last Post: 11-25-2002, 05:50 AM
  5. packed structs
    By moi in forum C Programming
    Replies: 4
    Last Post: 08-20-2002, 01:46 PM