NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

Compiler Warning (level 1) C4172

returning address of local variable or temporary

A function returns the address of a local variable or temporary object. Local variables and temporary objects are destroyed when a function returns, so the address returned is not valid. The following sample generates C4172:

int *func1() {
   int test = 1;
   return &test;      // C4172
}

/* use the following definition of func1 to resolve the warning
int *func1() {
   int test = 1;
   int* testptr = &test;
   return testptr;   
}
*/

void main() {
}