Re: question about memcpy()

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



"Ed Weir (ComCast)" <Anon@xxxxxxxx> wrote in message
news:bsydnTz9w9b0MdPZRVn-vQ@xxxxxxxxxxxxxx

"kathy" <yqin_99@xxxxxxxxx> wrote in message
news:1146006177.324850.224610@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
| Yes. You are right. No setting of /Zp in one project and another one
| has pack() setting.
|
| Could you explain why the first member of MAC_ADDR as a 6 byte array is
| problematic?
|

If default packing is 8, there will be two bytes slack...

I always use /Zp1.

- Ed.


I don't see that it's necessary to "always" use /Zp1. There are many
computations that are faster/more efficient if the default packing is used,
such that it's usually not necessry (or advisable) to compile the entire
project at /Zp1

You can force packings for particular structures that need them using the
"pack" #pragma:

#pragma (pack, temp_byte_packing, 1)

// your structures here

#pragma (pop, temp_byte_packing)

See http://msdn2.microsoft.com/en-us/library/2e70t5y1(VS.80).aspx

Mike


.



Relevant Pages

  • Re: padding mechanism in structures
    ... #pragma pack([n]) ... Specifies packing alignment for structure and union members. ... level by the pack pragma. ...
    (comp.lang.c)
  • Re: Packing for __nogc classes
    ... >of a struct/class does not specifically set a packing size, ... >pack directive, when the compiler saw the header file it would apply ... use #pragma pack on structs only as necessary. ... and Windows headers. ...
    (microsoft.public.dotnet.languages.vc)
  • Re: question about memcpy()
    ... default packing be used to be compatible with other components. ... #pragma pack ... this guarantees that your struct will be properly packed according to your specifications, ... such that it's usually not necessry to compile the entire ...
    (microsoft.public.vc.mfc)
  • Alignment issues with Sun C Compiler
    ... I have some serious problems with the pack() pragma with sun cc: ... I'd like to have the members of a few structures packed. ... whole structure at least on the natural alignment of the first member ...
    (comp.unix.solaris)
  • Readers share packing tips in light of new baggage fees
    ... Packing difficulties ... Ever since American started charging a fee for all checked bags, ... Pack separates that can be mixed and matched so you can wear ... Wear several layers of clothes onto the plane. ...
    (rec.travel.air)