www.digitalmars.com         C & C++   DMDScript  

c++ - AUTO variables error when I compile

reply "Alexandre" <alebencz gmail.com> writes:
I made this simple code sample, to show the erro:

#include <iostream>

using namespace std;

int main(int argc, char **argv)
{
   auto foo = "Ola mundo";
   auto bar = 15;

   cout << foo << " -> " << bar << endl;

   return 0;
}

and, when I try to build, I got that error:
$dmc main.cpp -I\dm\stlport\stlport
   auto foo = "Ola mundo";
                         ^
main.cpp(7) : Error: need explicit cast to convert
from: char const *
to  : int
--- errorlevel 1

Btw, how to use the auto variables ?
Apr 17 2014
parent "Hannes Steffenhagen" <cubicentertain gmail.com> writes:
Sounds like C++11 isn't enabled, auto is interpreted as a storage 
qualifier and the type is defaulted to int. There's probably some 
switch for dmc to enable C++11, I don't use it myself though.
Apr 19 2014