简体   繁体   中英

What does the PACKED keyword mean in Android aosp?

When I read some C++ code in the Android aosp, I see some classes are declared with a PACKED keyword. For example, in <android_source_root>/art/runtime/image.h , a class ImageSection is declared this way:

class PACKED(4) ImageSection {
 public:
  ImageSection() : offset_(0), size_(0) { }
  ImageSection(uint32_t offset, uint32_t size) : offset_(offset), size_(size) { }
  ImageSection(const ImageSection& section) = default;
  ImageSection& operator=(const ImageSection& section) = default;

What does the PACKED(4) mean?

It is defined in <android_source_root>/art/libartbase/base/macros.h

#define PACKED(x) __attribute__ ((__aligned__(x), __packed__))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM