Delen via


Compilerfout C3538

In een declaratielijst moet het type van 'auto' altijd hetzelfde blijven.

Opmerkingen

Alle gedeclareerde variabelen in een declaratielijst worden niet omgezet in hetzelfde type.

Deze fout corrigeren

  1. Zorg ervoor dat alle auto declaraties in de lijst tot hetzelfde type leiden.

Example

De volgende statements leiden tot C3538. Elke instructie declareert meerdere variabelen, maar elk gebruik van het auto trefwoord leidt niet af op hetzelfde type.

// 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 and c1 is char*, but 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;
}

Zie ook

automatisch trefwoord