揮発性のメモ2

http://d.hatena.ne.jp/iww/

2016-10-30から1日間の記事一覧

error: cannot bind packed field 'a.hoge_t::n' to 'int&'

C++

パックした構造体のメンバーは、参照で利用できない。 #include <iostream> using namespace std; struct hoge_t{ int n; } __attribute__((__packed__)); void setan( int &n ){ n = 123; } int main() { hoge_t a; setan( a.n ); // ★コンパイルエラー cout << a.n <</iostream>…