다음을 통해 공유


컴파일러 오류 C3538

선언자 목록에서 'auto'는 항상 같은 형식으로 추론해야 합니다.

선언 목록의 모든 선언된 변수가 같은 형식으로 해석되지 않습니다.

이 오류를 해결하려면

  • 목록의 모든 auto 선언이 같은 형식으로 추론되는지 확인합니다.

예제

다음 문에서는 C3538이 발생합니다. 각 문에 여러 개의 변수가 선언되어 있지만 각 auto 키워드가 같은 형식으로 추론되지 않습니다.

// C3538.cpp
// Compile with /Zc:auto
// C3538 expected
int main()
{
// Variable x1 is a pointer to char, but y1 is a double.
   auto * x1 = "a", y1 = 3.14;  
// Variable c is a char, but c1, c2, and c3 are pointers to pointers.
   auto c = 'a', *c1 = &c, * c2 = &c1, * c3 = &c2; 
// Variable x2 is an int, but y2 is a double and z is a char.
   auto x2(1), y2(0.0), z = 'a'; 
// Variable a is a pointer to int, but b is a pointer to double.
   auto *a = new auto(1), *b = new auto(2.0); 
   return 0;
}

참고 항목

참조

auto Keyword