Compiler Warning (level 4) C4221
Collapse the table of content
Expand the table of content
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

Compiler Warning (level 4) C4221

Error Message

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.


// 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).

© 2015 Microsoft