为什么VC ++不接受(打包)? [英] Why can't VC++ accept (packed)?
本文介绍了为什么VC ++不接受(打包)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个代码段:
I have a code snippet:
typedef struct tagBITMAPFILEHEADER {
WORD bfType;
DWORD bfSize;
WORD bfReserved1;
WORD bfReserved2;
DWORD bfOffBits;
} __attribute__((packed)) BITMAPFILEHEADER;
我使用VC ++ 2012编译它并收到错误消息:
1> D:\ programs\ATP-3 \ATP3MMI \ MMI\include\sys-include \ Windows32 / Structures.h(210):错误C2065:'packed':未声明的标识符
怎么来的?
我尝试过:
我用关键字打包,编译器选项,VC ++搜索,发现所有这些都无法帮助我解决它。
I compiled it using VC++2012 and got error message:
1>D:\programs\ATP-3\ATP3MMI\MMI\include\sys-include\Windows32/Structures.h(210): error C2065: 'packed' : undeclared identifier
How come?
What I have tried:
I googled with keywords "packed", "compiler options", "VC++" and found all of them can't help me to figure it.
推荐答案
因为它是非标准的扩展,在GCC中使用。
对于VS,你想要 #pragma pack [ ^ ]
Because it's a nonstandard extension, used in GCC.
For VS, you want #pragma pack[^]
使用Microsoft C ++
编译器,要走的路是 pragma pack [ ^ ]。
With the Microsoft C++
compiler, the way to go is the pragma pack[^].
这篇关于为什么VC ++不接受(打包)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文