的數據類型,我想創建的大小508個字節的結構。如何創建一個給定大小
查看此代碼,我推斷,我可以創建任意大小我想要的結構。
#include <stdint.h>
/**
* Common Data Types
*
* The data types in this section are essentially aliases for C/C++
* primitive data types.
*
* Adapted from http://msdn.microsoft.com/en-us/library/cc230309(PROT.10).aspx.
* See http://en.wikipedia.org/wiki/Stdint.h for more on stdint.h.
*/
typedef uint8_t BYTE;
typedef uint32_t DWORD;
typedef int32_t LONG;
typedef uint16_t WORD;
/**
* BITMAPFILEHEADER
*
* The BITMAPFILEHEADER structure contains information about the type, size,
* and layout of a file that contains a DIB [device-independent bitmap].
*
* Adapted from http://msdn.microsoft.com/en-us/library/dd183374(VS.85).aspx.
*/
typedef struct
{
WORD bfType;
DWORD bfSize;
WORD bfReserved1;
WORD bfReserved2;
DWORD bfOffBits;
} __attribute__((__packed__))
BITMAPFILEHEADER;
我需要的大小508個字節int類型,之後我看到這篇文章:Size of the given structure我想象我可以創建的大小,我需要的INT。所以,我試圖創建一個結構,像這樣:
typedef struct
{
int datachunk : 4064;
}
BLOCK;
當然,這是野生的想象力和我錯了。
所以,我怎麼能創造出大小508個字節的結構包含相同大小的數據類型整數(即4064
沒有內置的整數,大型的任何實現我所知道的。如果你真的需要一個4064位的整數,你將不得不使用一些大的整數實現,這有效地創建一個大的整數出多個較小的整數。 –