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

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

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

問(wèn)題描述

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

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

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è)字段的長(zhǎng)度(以位為單位).

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)

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

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

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

【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(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?(如何將枚舉類(lèi)型變量轉(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)嗎?)
主站蜘蛛池模板: 日韩黄色影院 | 亚洲日本天堂 | 中文字幕二区 | 91调教打屁股xxxx网站 | 久久精品视频网站 | 亚洲涩涩涩 | 精品网站999www| 久久亚洲国产 | 天天色网站 | 亚洲在线播放 | 免费成人黄色 | 亚洲第一区视频 | 欧美日韩精品久久久免费观看 | 涩五月婷婷 | 欧美精品一区二区在线观看 | 成人毛片100免费观看 | 国产一区二区av | 四虎影院最新地址 | 伊人网av | 色婷婷色| 日本不卡中文字幕 | 视频一区二区在线 | 国产精品自在线 | 亚洲免费视频一区 | www.久草.com| 国产午夜一区 | 日韩精品免费看 | 久久久久九九九九 | 风间由美一区二区三区 | 国产精品免费在线 | 国产伦精品一区二区三区在线 | 国产精品久久久久久久成人午夜 | 黄色在线小视频 | 91久久久久久久久久 | 黄色1级片 | 久草视频在线播放 | 欧美日韩精品久久久免费观看 | 综合久久99| 97中文字幕| 成人午夜网 | 色综合88 |