CArchive :: operator的行为更改<< (bool b) [英] Change in behavior of CArchive::operator << (bool b)

查看:107
本文介绍了CArchive :: operator的行为更改<< (bool b)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当CArhive :: operator的行为<<时,有人知道MFC的版本吗? (bool b)从将bool转换为LONG(MFC 6)更改为将其转换为BYTE(MFC 9及更高版本)?

这很重要,因为如果您做得不好,LONG和BYTE大小的差异将完全破坏在不同约定下存储/加载的文件的序列化.我想让文件_MFC_VER知道并使用适合于单个文件的约定(4或1个字节),但是我需要知道约定何时更改,并且现在我不能再将其范围缩小而不是发生在Studio 6和Studio 9之间的地方.可悲的是,无论是Google还是对Code Project的扫描都没有得出任何答案.

谢谢,

Michael Waters

Does anybody know the version of MFC when the behavior of CArhive::operator << (bool b) changed from casting bool to LONG (MFC 6) to casting it to BYTE (MFC 9 and up)?

This is a big deal, since if you don''t get it right, the difference in size of LONG and BYTE will completly wreck the serialization of files stored/loaded under different conventions. I want to make the files _MFC_VER aware and use the convention (4 or 1 bytes) as appropriate to the individual file, but I need to know just when the convention changed, and right now, I can''t narrow it down any more than that it happened somewhere between Studio 6 and Studio 9. Sadly, neither Google or a scan of Code Project has yielded any answers.

Thanks,

Michael Waters

推荐答案

从VC ++ 2003开始就是如此.布尔值现在为bool类型,而不是BOOL.

内在的bool 的长​​度为1个字节.因此,如果您希望使用旧的行为,请不要使用bool 成员字段或本地变量,而应使用BOOL (它仍然可以按您期望的方式工作).
This has been so since VC++ 2003. Boolean values are now of type bool instead of BOOL.

And the intrinsic bool is 1 byte in length. So if you want the old behavior do not use bool member fields or locals, and instead use BOOL (which will still work as you expect it to).


我建​​议最好不要将其设为_MFC_VER,而是建议您在每个档案中存储自己的档案版本号.这样,无需考虑MFC版本或任何其他基于编译器的变量,就可以处理文件结构的将来更新.
I would suggest that instead of making it _MFC_VER aware, you''d be well advised to store your own archive version number in each archive. That way, future updates to the file structure can be handled without regard to MFC version or any other compiler-based variable.


这篇关于CArchive :: operator的行为更改&lt;&lt; (bool b)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆