Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a C++11/14 alternative to __attribute__((packed))

C++11 introduced a concept of standardized attribute syntax. I couldn't find the list of all supported attributes. Is there a C++11 attribute alternative to __attribute__((packed))?

e.g.

struct __attribute__((packed)) Pack {
   uint8_t field1;
   uint8_t field2;
};
like image 568
Crossfire Avatar asked Nov 16 '15 14:11

Crossfire


1 Answers

Unfortunately, no. The attributes the standard currently defines are:

  • [[noreturn]];
  • [[carries_dependency]];
  • [[deprecated]]/[[deprecated(reason)]];

Everything else is implementation-defined.

like image 131
edmz Avatar answered Sep 29 '22 21:09

edmz