Skip to content

Latest commit

 

History

History
36 lines (29 loc) · 840 Bytes

compiler-warning-level-4-c4221.md

File metadata and controls

36 lines (29 loc) · 840 Bytes
description title ms.date f1_keywords helpviewer_keywords ms.assetid
Learn more about: Compiler Warning (level 4) C4221
Compiler Warning (level 4) C4221
11/04/2016
C4221
C4221
8532bd68-54dc-4526-8597-f61dcb0a0129

Compiler Warning (level 4) C4221

nonstandard extension used : 'identifier' : cannot be initialized using address of automatic variable

With the default Microsoft extensions (/Ze), you can initialize an aggregate type (array, struct, or union) with the address of a local (automatic) variable.

Example

// C4221.c
// compile with: /W4
struct S
{
   int *i;
};

void func()
{
   int j;
   struct S s1 = { &j };   // C4221
}

int main()
{
}

Such initializations are invalid under ANSI compatibility (/Za).