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).
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for