分享方式:


編譯器警告 (層級 4) C4764

無法對齊超過 16 位元組的攔截物件

已指定大於 16 的對齊,但是在某些平台,如果函式擲回例外狀況,堆疊就會強制不大於 16 的對齊方式。

範例

下列範例會產生 C4764:

// C4764.cpp
// compile with: /W4 /EHsc
// processor: x64 IPF
#include <stdio.h>

class A
{
public:
    int x;
};

typedef __declspec(align(32)) A ALIGNEDA;

int main()
{
    ALIGNEDA a;
    try
    {
        a.x = 15;
        throw a;
    }
    catch (ALIGNEDA b) // can't align b to > 16 bytes
    {
        printf_s("%d\n", b.x);
    }
}   // C4764