久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

結(jié)構(gòu)或聯(lián)合中的“無符號(hào)臨時(shí):3"是什么意思

What does #39;unsigned temp:3#39; in a struct or union mean?(結(jié)構(gòu)或聯(lián)合中的“無符號(hào)臨時(shí):3是什么意思?)
本文介紹了結(jié)構(gòu)或聯(lián)合中的“無符號(hào)臨時(shí):3"是什么意思?的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

可能的重復(fù):
這段 C++ 代碼是什么意思?

我正在嘗試使用 JNA 將 C 結(jié)構(gòu)映射到 Java.我遇到了一些我從未見過的東西.

I'm trying to map a C structure to Java using JNA. I came across something that I've never seen.

struct 定義如下:

struct op 
{
    unsigned op_type:9;  //---> what does this mean? 
    unsigned op_opt:1; 
    unsigned op_latefree:1; 
    unsigned op_latefreed:1; 
    unsigned op_attached:1; 
    unsigned op_spare:3; 
    U8 op_flags; 
    U8 op_private;
};

您可以看到定義了一些變量,例如 unsigned op_attached:1,但我不確定這意味著什么.這會(huì)影響要為此特定變量分配的字節(jié)數(shù)嗎?

You can see some variable being defined like unsigned op_attached:1 and I'm unsure what would that mean. Would that effect the number of bytes to be allocated for this particular variable?

推薦答案

此構(gòu)造指定每個(gè)字段的長度(以位為單位).

This construct specifies the length in bits for each field.

這樣做的好處是你可以控制sizeof(op),如果你小心的話.結(jié)構(gòu)的大小將是內(nèi)部字段大小的總和.

The advantage of this is that you can control the sizeof(op), if you're careful. the size of the structure will be the sum of the sizes of the fields inside.

在您的情況下,op 的大小為 32 位(即 sizeof(op) 為 4).

In your case, size of op is 32 bits (that is, sizeof(op) is 4).

對(duì)于每組未簽名的 xxx:yy,大小總是向上取整到下一個(gè) 8 的倍數(shù);構(gòu)造.

The size always gets rounded up to the next multiple of 8 for every group of unsigned xxx:yy; construct.

這意味著:

struct A
{
    unsigned a: 4;    //  4 bits
    unsigned b: 4;    // +4 bits, same group, (4+4 is rounded to 8 bits)
    unsigned char c;  // +8 bits
};
//                    sizeof(A) = 2 (16 bits)

struct B
{
    unsigned a: 4;    //  4 bits
    unsigned b: 1;    // +1 bit, same group, (4+1 is rounded to 8 bits)
    unsigned char c;  // +8 bits
    unsigned d: 7;    // + 7 bits
};
//                    sizeof(B) = 3 (4+1 rounded to 8 + 8 + 7 = 23, rounded to 24)

我不確定我是否記得正確,但我想我沒記錯(cuò).

I'm not sure I remember this correctly, but I think I got it right.

這篇關(guān)于結(jié)構(gòu)或聯(lián)合中的“無符號(hào)臨時(shí):3"是什么意思?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Algorithm to convert RGB to HSV and HSV to RGB in range 0-255 for both(將 RGB 轉(zhuǎn)換為 HSV 并將 HSV 轉(zhuǎn)換為 RGB 的算法,范圍為 0-255)
How to convert an enum type variable to a string?(如何將枚舉類型變量轉(zhuǎn)換為字符串?)
When to use inline function and when not to use it?(什么時(shí)候使用內(nèi)聯(lián)函數(shù),什么時(shí)候不使用?)
Examples of good gotos in C or C++(C 或 C++ 中好的 goto 示例)
Significance of ios_base::sync_with_stdio(false); cin.tie(NULL);(ios_base::sync_with_stdio(false) 的意義;cin.tie(NULL);)
Is TCHAR still relevant?(TCHAR 仍然相關(guān)嗎?)
主站蜘蛛池模板: 亚洲 中文 欧美 日韩 在线观看 | 粉嫩一区二区三区国产精品 | 成人免费视频网站在线看 | www.日本三级 | 二区中文 | 91精品国产乱码久久久久久久久 | 一二三区av| 午夜不卡一区二区 | 亚洲精品乱码久久久久久蜜桃 | 免费黄色日本 | 九九热视频这里只有精品 | 妖精视频一区二区三区 | www操操 | 欧美一级二级在线观看 | 国产亚洲精品91 | 天天夜碰日日摸日日澡 | 国产精品国产亚洲精品看不卡15 | 久久久久久国产精品免费免费狐狸 | 成人亚洲精品 | 特黄一级 | 欧美一级特黄aaa大片在线观看 | 欧美精品一二区 | 99久久99热这里只有精品 | 黄色一级大片在线免费看产 | 国产99久久久久 | 精品国产视频在线观看 | 美女一区 | 免费观看成人性生生活片 | 亚洲精品视频一区 | 日本三级在线视频 | 国产精品有限公司 | 国产乱码精品1区2区3区 | a视频在线| av大全在线 | 国产婷婷精品av在线 | 中文在线一区二区 | 日韩成人性视频 | 欧美理伦片在线播放 | 国产精品成人一区二区三区 | 精品自拍视频在线观看 | 操久久 |