0

本文有一个关于TASKDIALOGCONFIG使用结构的深入教程。在该教程中,它指出:

以下代码创建了一个最小的任务对话框:

TASKDIALOGCONFIG config = { sizeof (TASKDIALOGCONFIG) };

在我的代码中,我有类似的东西:

TASKDIALOGCONFIG sConfig = { sizeof(TASKDIALOGCONFIG) };

那么,为什么代码分析会说:

警告C26476:表达式/符号{0}使用带有多个类型指针的裸联合“联合”:改用变体 (type.7)。

我们最近进行了一次讨论,提出了使用std::variant. 但这种结构被定义为:

typedef struct _TASKDIALOGCONFIG
{
    UINT        cbSize;
    HWND        hwndParent;                             // incorrectly named, this is the owner window, not a parent.
    HINSTANCE   hInstance;                              // used for MAKEINTRESOURCE() strings
    TASKDIALOG_FLAGS                dwFlags;            // TASKDIALOG_FLAGS (TDF_XXX) flags
    TASKDIALOG_COMMON_BUTTON_FLAGS  dwCommonButtons;    // TASKDIALOG_COMMON_BUTTON (TDCBF_XXX) flags
    PCWSTR      pszWindowTitle;                         // string or MAKEINTRESOURCE()
    union
    {
        HICON   hMainIcon;
        PCWSTR  pszMainIcon;
    } DUMMYUNIONNAME;
    PCWSTR      pszMainInstruction;
    PCWSTR      pszContent;
    UINT        cButtons;
    const TASKDIALOG_BUTTON  *pButtons;
    int         nDefaultButton;
    UINT        cRadioButtons;
    const TASKDIALOG_BUTTON  *pRadioButtons;
    int         nDefaultRadioButton;
    PCWSTR      pszVerificationText;
    PCWSTR      pszExpandedInformation;
    PCWSTR      pszExpandedControlText;
    PCWSTR      pszCollapsedControlText;
    union
    {
        HICON   hFooterIcon;
        PCWSTR  pszFooterIcon;
    } DUMMYUNIONNAME2;
    PCWSTR      pszFooter;
    PFTASKDIALOGCALLBACK pfCallback;
    LONG_PTR    lpCallbackData;
    UINT        cxWidth;                                // width of the Task Dialog's client area in DLU's. If 0, Task Dialog will calculate the ideal width.
} TASKDIALOGCONFIG;

那么我们如何绕过这个警告呢?

4

0 回答 0