Lưu ý
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử đăng nhập hoặc thay đổi thư mục.
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử thay đổi thư mục.
VARIANT 'var' was cleared when it was uninitialized (expression 'expr')
Remarks
This warning is triggered when an uninitialized VARIANT is passed to an API, such as VariantClear, that clears the object. Initialize the VARIANT before passing it to these functions so it can be properly cleared.
This warning applies to these functions:
VariantClearPropVariantClearVariantCopyVariantCopyIndVariantChangeTypeVariantChangeTypeExDestroyPropVariant
Code analysis name: VARIANTCLEAR_UNINITIALIZED
Example
The following code causes warning C33001:
#include <Windows.h>
HRESULT foo(bool some_condition)
{
VARIANT var;
if (some_condition)
{
//...
VariantInit(&var);
//...
}
VariantClear(&var); // C33001
}
In this example, the warning is corrected by calling VariantClear only after var has been initialized:
#include <Windows.h>
HRESULT foo(bool some_condition)
{
VARIANT var;
if (some_condition)
{
//...
VariantInit(&var);
//...
VariantClear(&var); // OK
}
}