久久久久久久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)嗎?)
主站蜘蛛池模板: 欧美精品亚洲 | 福利视频网站 | 欧美成人久久 | 日韩av在线不卡 | 日韩二区三区 | 国产成人精品亚洲 | 九九精品在线观看 | 天天操天天干天天爽 | 亚洲成人毛片 | 91日韩欧美 | 亚洲精品18在线观看 | 伦一理一级一a一片 | 夜夜草av| 日韩亚洲天堂 | 最新国产在线视频 | 一级片欧美 | 午夜无遮挡 | 日韩高清在线播放 | 久久黄色网址 | 一级片久久 | 国产精品久久久999 成人在线国产 | 亚洲专区在线 | 久久久国产精品人人片 | 亚洲欧美在线观看视频 | 欧美黄色片视频 | av四虎 | 91久久精品日日躁夜夜躁欧美 | 一区二区三区在线观看视频 | 九色av| 三级a毛片 | 手机福利视频 | 国内精品视频在线观看 | 国产午夜视频在线观看 | 亚洲精品自拍视频 | 在线视频日韩 | 久久靖品 | 每日更新av | 久久免费观看视频 | 九九热在线视频 | 国产一区精品视频 | 日韩特级毛片 |