Android aosp 中的 PACKED 关键字是什么意思?

What does the PACKED keyword mean in Android aosp?

当我阅读 Android aosp 中的一些 C++ 代码时,我看到一些 classes 是用 PACKED 关键字声明的。例如,在<android_source_root>/art/runtime/image.h中,一个classImageSection是这样声明的:

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;

PACKED(4) 是什么意思?

定义在<android_source_root>/art/libartbase/base/macros.h

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