-2

I used to compile the following code:

const std::map<std::string, bool> pending_achs = The result from this method std::map<std::string, bool> get_pending_ach_modifications() const { return stuff; };

And

    for (auto const& [key, val] : pending_achs) {
        if(val) {
            // Stuff
        } else {
            // Stuff              
        }
    }

I think this sould be valid code after reading this answer.

I'm building my code with this command:

g++ -std=c++17 -g \
`pkg-config --cflags gtk+-3.0` \
-rdynamic -export-dynamic -pthread -Wall \
SAM.Picker/*.cpp \
common/*.cpp \
-L$SCRIPTPATH/bin \
-o $SCRIPTPATH/bin/samrewritten \
`pkg-config --libs gtk+-3.0` \
-lpthread -lgmodule-2.0 -lsteam_api -lcurl

But I get the following error:

SAM.Picker/gtk_callbacks.cpp: In function ‘void on_store_button_clicked()’:
SAM.Picker/gtk_callbacks.cpp:42:26: error: expected unqualified-id before ‘[’ token
         for (auto const& [key, val] : pending_achs) {
                          ^
SAM.Picker/gtk_callbacks.cpp:42:26: error: expected ‘;’ before ‘[’ token
SAM.Picker/gtk_callbacks.cpp:42:27: error: ‘key’ was not declared in this scope
         for (auto const& [key, val] : pending_achs) {
                           ^~~
SAM.Picker/gtk_callbacks.cpp:42:32: error: ‘val’ was not declared in this scope
         for (auto const& [key, val] : pending_achs) {
                                ^~~
SAM.Picker/gtk_callbacks.cpp: In lambda function:
SAM.Picker/gtk_callbacks.cpp:42:37: error: expected ‘{’ before ‘:’ token
         for (auto const& [key, val] : pending_achs) {
                                     ^
SAM.Picker/gtk_callbacks.cpp: In function ‘void on_store_button_clicked()’:
SAM.Picker/gtk_callbacks.cpp:42:37: error: expected ‘;’ before ‘:’ token
SAM.Picker/gtk_callbacks.cpp:42:37: error: expected primary-expression before ‘:’ token
SAM.Picker/gtk_callbacks.cpp:42:37: error: expected ‘)’ before ‘:’ token
SAM.Picker/gtk_callbacks.cpp:42:37: error: expected primary-expression before ‘:’ token

And yes the line before the error ends with a semicolon.

I'm pretty sure this is something really stupid and I will end up deleting this question but I've been stuck on this for a while now and I'd really appeciate some help.

Thank you all

EDIT: My GCC version:

[name@name-pc ~]$ g++ -v
Utilisation des specs internes.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.1/lto-wrapper
Cible : x86_64-pc-linux-gnu
Configuré avec: /build/gcc/src/gcc/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared --enable-threads=posix --enable-libmpx --with-system-zlib --with-isl --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch --disable-libssp --enable-gnu-unique-object --enable-linker-build-id --enable-lto --enable-plugin --enable-install-libiberty --with-linker-hash-style=gnu --enable-gnu-indirect-function --enable-multilib --disable-werror --enable-checking=release --enable-default-pie --enable-default-ssp --enable-cet=auto
Modèle de thread: posix
gcc version 8.2.1 20180831 (GCC)
yhu420
  • 436
  • 6
  • 18

1 Answers1

0

Alright, I found out. I installed Visual Studio Code with Flatpak. Everytime I tried compiling, it was from within the IDE, whih used GCC 6.4.

Sorry for wasting everyone's time. I'll still let this thread up since it could help a lost soul as well.

yhu420
  • 436
  • 6
  • 18