bit-fields

    0熱度

    1回答

    該聯合的大小返回16字節(在C++ Builder 2007中)。 typedef union { struct { unsigned Type:2; unsigned Prev:31; unsigned Next:31; unsigned SizeInBytes:32; }; } eMyUnion; 如何修改這個聯合定

    2熱度

    3回答

    我不知道該怎麼稱呼它,所以我不知道如何搜索它。 unsigned int odd : 1; 編輯: 要細說,它來自這個片段: struct bitField { unsigned int odd : 1; unsigned int padding: 15; // to round out to 16 bits }; 我推測這涉及到位,但我仍然不是所有的理解方式。

    7熱度

    3回答

    #include <stdint.h> #include <stdio.h> typedef union { uint64_t u[2]; struct { uint64_t a:30; uint64_t b:30; uint64_t c:30; uint64_t d:30; uint64_t e:8;

    2熱度

    1回答

    我試圖更多地瞭解位字段的工作原理。 考慮下面的代碼: 並假設int是32位 #include <stdio.h> int main() { struct byte { int one:1; }; struct byte var = {3}; printf("%d\n", var.one); printf("%#x\n",

    1熱度

    1回答

    我們有十幾個模擬器在UDP上相互交談。接口定義在數據庫中進行管理。模擬器使用不同的語言編寫;大多數是C++,一些是Java和C#。目前,當系統工程師在接口定義數據庫中進行更改時,模擬器開發人員會手動更新其代碼中的通信數據結構。消息大部分是2-5個字節,每個信號都有位字段。我想要做的是從接口定義數據庫生成一個描述字節和位字段定義的文件,並讓每個開發人員以最小的麻煩將其添加到他的模擬器代碼中。 Bar

    2熱度

    2回答

    在下面的代碼 #include <iostream> using namespace std; struct field { unsigned first : 5; unsigned second : 9; }; int main() { union { field word; int i; }; i

    1熱度

    2回答

    哪些位域有用?

    0熱度

    1回答

    我試圖在Objective-C中做一個1位的實例字段,但是當我嘗試這樣做時@property BYTE Z : 1;我得到一個錯誤,說Property name cannot be a bitfield。 我不能這樣做?有沒有解決這個錯誤? 由於

    4熱度

    5回答

    我想知道爲什麼位域可以與工會/結構一起工作,但不能和像int或short這樣的正常變量一起工作。 這工作: struct foo { int bar : 10; }; 但這種失敗: int bar : 10; // "Expected ';' at end of declaration" 爲什麼這個功能僅在工會/結構,而不是與變量可用?技術不一樣嗎? 編輯: 如果將允許你能與例

    4熱度

    2回答

    可能重複: C++ bitfield packing with bools 它是保證安全使用位域定義中C++的bool關鍵字? 喜歡的東西: struct flags { bool a : 1; bool b : 1; }