bufftowel
bufftowel

Reputation: 45

Have g++ follow C++14 ISo standards, compiler flags - what do they actually mean?

I recently read about compilers and the gcc (kinda new to programming), i tried to use auto in my code which gave me an error showing "auto has different meaning in c++11", so i googled it and found that i need c++11 or c++14 support, and so i enabled "Have g++ follow c++14 ISO standards" in compiler setting and it started working, in the compiler setting there were a bunch of more option which i came to know are apparently called "flags" now, i am a bit confused as to what these flags actually are and did my compiler already had support for c++14?, or do i still need to download a separate compiler to use c++14, i am using code blocks 17.2.It would be really helpful if someone could provide links to read more about what flags actually are and what is deal with g++/c++11/c++14 and what shall i be using.

These are the options i am talking about :-

enter image description here

Upvotes: 0

Views: 400

Answers (2)

Constantinos Glynos
Constantinos Glynos

Reputation: 3186

All this means is that g++ will compile with the following arguments to comply with the according standard.

g++ -std=c++11 foo.cpp -o foo

means that g++ will compile foo.cpp using the C++11 standard

g++ -std=c++14 foo.cpp -o foo

means that g++ will compile foo.cpp using the C++14 standard

The difference is that the following code will not compile when the c++11 argument is used, but will compile under c++14.

auto func()
{
    return 2;
}

int main()
{
    int a = func();
}

Upvotes: 1

Rietty
Rietty

Reputation: 1156

The flags are used in order to decide which standard to use when compiling the code, and in turn this means that if you are using features that are not in your current standard and are in a newer one, then the compiler will complain about it.

Upvotes: 3

Related Questions