gpt4 book ai didi

C++ 运算符 & 与枚举的计算结果为 false

转载 作者:行者123 更新时间:2023-11-30 01:08:36 26 4
gpt4 key购买 nike

以下代码输出 reportAllDataRanges = 0。

BOOLEAN updateDataRanges = IsFirstUpdate || (m_uiDataRangeMode & IAdapterCommon::UpdatePinDataRanges);
BOOLEAN updateConstrainedDataRanges = m_uiDataRangeMode & IAdapterCommon::UpdatePinConstrainedDataRanges;
BOOLEAN reportAllDataRanges = m_uiDataRangeMode & IAdapterCommon::ReportAllDataRanges;

DPF_ENTER(("[CAdapterCommon::UpdatePinDescriptor(%p, %lu)] - m_uiDataRangeMode = %lu, updateDataRanges = %lu, updateConstrainedDataRanges = %lu, reportAllDataRanges = %lu, a & b = %lu, b = %lu", PinDescriptor, IsFirstUpdate, m_uiDataRangeMode, updateDataRanges, updateConstrainedDataRanges, reportAllDataRanges, m_uiDataRangeMode & IAdapterCommon::ReportAllDataRanges, IAdapterCommon::ReportAllDataRanges));

[CAdapterCommon::UpdatePinDescriptor(FFFFF8064CCE42F0, 1)] - m_uiDataRangeMode = 3070, updateDataRanges = 1, updateConstrainedDataRanges = 64, reportAllDataRanges = 0, a & b = 512, b = 512

typedef enum : UINT32
{
None = 0,
UseDataRanges = 1 << 0,
UseDiscreteDataRanges = 1 << 1,
RaiseUpdateEvent = 1 << 2,
RaiseUpdatePinDescriptor = 1 << 3,
DoNotUpdateOriginalDescriptor = 1 << 4,
UpdatePinDataRanges = 1 << 5,
UpdatePinConstrainedDataRanges = 1 << 6,
UseDataRangeIntersection = 1 << 7,
UseProposedDataFormat = 1 << 8,
ReportAllDataRanges = 1 << 9,
DataRangeIntersectionAcceptAllRanges = 1 << 10,
SupportedDataRangesFirst = 1 << 11,
} DataRangeModeEnum;

不应该

BOOLEAN value = 3070 & 512;

评估为 TRUE? (大于零)?

最佳答案

我认为您使用的是 <Windows.h> 中的 BOOLEAN 类型header 是 BYTE 类型的 typedef,它是 unsinged char 类型的 typedef,它可以保存 0 - 255 的值,而不是 3070 & 512 到的 512。表达式求值。存在导致值 0 的溢出,相当于 FALSE .

关于C++ 运算符 & 与枚举的计算结果为 false,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42124241/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com