Apple Developer Connection
Advanced Search
Member Login Log In | Not a Member? Contact ADC

< Previous PageNext Page >

アーカイブ済みビットフィールド

整数のビットフィールドを含んでいる構造体はNSArchivesクラスを使用してアーカイブしないのが最善です。個々の値はアーキテクチャとコンパイラに依存した方法で、アーカイブに保存されます。アーカイブにこのような構造体がすでに含まれている場合は、Listing 4-1に示すように、ビットフィールドを適切にスワップするように宣言を変更することで、構造体を正しく読み取ることができます。

このような変更が他のコードに影響を与えないか、コードを調べる必要が生じることもあります。この解決策はGCCに固有です。

Listing 4-1  ビットフィールドをスワップする構造体

typedef struct {
#ifdef __BIG_ENDIAN__
    unsigned int rotatedFromBase:1;
    unsigned int aboutToResize:1;
    unsigned int stuff:30;
#else
    unsigned int stuff:30;
    unsigned int aboutToResize:1;
    unsigned int rotatedFromBase:1;
#endif
}   _flags;


< Previous PageNext Page >


Last updated: 2006-03-08




Did this document help you?
Yes: Tell us what works for you.

It’s good, but: Report typos, inaccuracies, and so forth.

It wasn’t helpful: Tell us what would have helped.
Get information on Apple products.
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Copyright © 2007 Apple Inc.
All rights reserved. | Terms of use | Privacy Notice