久久久久久久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)嗎?)
主站蜘蛛池模板: 国产欧美在线一区二区 | 久久国产亚洲 | 亚洲一区二区三区四区五区中文 | 97视频久久 | 欧美xxxx黑人又粗又长 | 国产欧美一区二区三区在线看 | 欧美日韩国产一区二区三区 | 男人天堂久久 | 久久免费小视频 | 国产欧美一区二区精品久导航 | 一区二区在线不卡 | 国产丝袜一区二区三区免费视频 | 亚洲精品久久久蜜桃 | 婷婷久久综合 | 另类a v| 伊人91在线 | 五月天激情电影 | 日韩在线视频一区 | 精品国产乱码久久久久久a丨 | 亚洲综合在线视频 | 不卡一区二区三区四区 | 欧美色视频免费 | 国产精品久久久久一区二区三区 | 美女一级a毛片免费观看97 | 亚洲综合精品 | 四虎永久影院 | 九一在线 | 91麻豆精品国产91久久久久久 | 亚洲欧美综合 | 国产精品成人一区二区 | 久久69精品久久久久久久电影好 | 欧美久久久久久 | 精品久久久久久亚洲精品 | 久久一热| 久久最新精品视频 | 欧美一区二区三区在线观看 | 欧美成人久久 | 亚洲一区二区视频在线播放 | 国产精品久久久久久久久久久免费看 | 欧美一区二区另类 | 免费在线一区二区 |