Re: C++ version 11 "auto"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



You'll probably need to add the flag: -std=c++11

On Sat, Apr 16, 2016 at 9:06 AM, Barry Gold <barrydgold@xxxxxxxxx> wrote:
> I've written a program that uses the STL, and recently came across the
> concept of automatic type determination. Which I think is *brilliant* btw.
>
> My code includes the following:
>
> In game.h:
> map<string, string> idlist;
>
> In Game.cpp:
> void Game::addID(string id)
> {
>     auto eltp = idlist.find(id);
>     if (eltp == map::end) {
>         idlist.insert(pair<string,string>(id, id));
>     } else {
>         // Found in map, so it's a duplicate
>         string emsg = "Duplicate ID: %s";
>         emsg += id;
>         yyerror(emsg);
>     }
> }
>
> =====
>
> My make log includes the following error message:
>
> g++    -c -o Game.o Game.cpp
> Game.cpp: In member function ‘void Game::addID(std::string)’:
> Game.cpp:12:10: error: ‘eltp’ does not name a type
>      auto eltp = idlist.find(id);
>           ^
> Game.cpp:13:9: error: ‘eltp’ was not declared in this scope
>      if (eltp == map::end) {
>          ^
>
> This seems to imply that g++ is using the old meaning of "auto": allocate
> the variable on the stack. Yet my gcc/g++ identifies as version 5.3.0, which
> the docs claim supports C++ version 11.
>
> Do I have to add a command-line flag to enable C++ version 11 and/or the new
> meaning of "auto"?
>
> FWIW, I'm using gcc in the gcc package of cygwin 2.5.0 (32-bit)
>
>
>
> --
> On Beta, we'd have earrings for that. You could buy them in any jewelry
> store. http://www.conchord.org/xeno/bdgsig.html



-- 
Best regards,
Daniël Bos


Your government is reading your email. Slow them down with encryption.

My public key: http://goo.gl/gms497 (4096 bit RSA, id EF2D5D91)
Fingerprint  : D8D0 9FBE F075 F709 7B52  2F73 326C 2123 EF2D 5D91




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux