fdsfdsfdsfds fdsfdsfdsfds - 1 month ago 16
C++ Question

extended initializer lists only available with -std=c++11 or -std=gnu++11

I get this error, porting a code from c to c++ :


src/common/atom.cpp:19:8: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11


void Atom::Run(ThreadFunction threadFunction)
{
mutex = PTHREAD_MUTEX_INITIALIZER;
if(threadFunction!=NULL)
{
pthread_create(&threadID, NULL, threadFunction, this);
this->running=true;
}
}


Edit : The question was , why do I need this flag in C++ but not in C, and what are initializers.

Answer

Problem

src/common/atom.cpp:19:8: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11

Solution

As you can see on the error it tells you to have the flags

std=c++11 or -std=gnu++11

This is so you have version : C++11 . Initalizer lists require C++11 .

With the version of C++11 , you have many additonal feutures like Lambda Expressions , Automatic Type Deduction and decltype , Uniform Initialization Syntax, Deleted and Defaulted Functions , nullptr, Rvalue References , New Smart Pointer Classes(shared_ptr,unique_ptr), C++11 Standard Library , More C++ Algorithms, and much more!

Refrences

C++11 FAQ - Bjarne Stroustrup

Comments