(C++) 'auto' will change meaning in C++0x; please remove it

February 24, 2017 · View on GitHub

 

 

 

 

 

(C++) 'auto' will change meaning in C++0x; please remove it

 

Compile warning.

 

 

 

 

 

Full warning message

 


MyMain.cpp:3: warning: 'auto' will change meaning in C++0x; please remove it

 

 

 

 

 

Cause

 

IDE: Qt Creator 1.2.1

Compiler: G++ 4.4.1

Project type: Qt4 Console Application

 


int main() {   auto int x = 3; }

 

 

 

 

 

Solution

 

Remove auto. Never use auto [1], until C++11 arrives.

 

 

 

 

 

References

 

  1. Herb Sutter. Exceptional C++ style. 2005. ISBN: 0-201-76042-8. Item 28 guideline: 'Never write auto'.