makefile has error when commands work on their own

makefile has error when commands work on their own

par Jasper Kranias,
Nombre de réponses : 4
When I use each command in my makefile manually in the terminal (Mac) everything runs fine, but when I use make it gives the warning:
 
warning: alias declarations are a C++11 extension [-Wc++11-extensions]

using Cells = std::unique_ptr<bool[]>;

and the errors:

init.cpp:10:21: error: no member named 'make_unique' in namespace 'std'

    Cells cell(std::make_unique<bool[]>(num_cells));

               ~~~~~^

init.cpp:10:37: error: expected '(' for function-style cast or type construction

    Cells cell(std::make_unique<bool[]>(num_cells));


does anyone have any idea why the makefile would cause these errors when the commands themselves don't?

En réponse à Jasper Kranias

Re: makefile has error when commands work on their own

par Ramses van Zon,
You need to tell your compiler to use the C++17 standard. See the example on slide 24 of lecture 5.
En réponse à Jasper Kranias

Re: makefile has error when commands work on their own

par Jagdeep Singh,
Unique ptr is not available in C++11
En réponse à Jagdeep Singh

Re: makefile has error when commands work on their own

par Ramses van Zon,
It's actually make_unique that is not available in c++11, but it is in c++17, which is what, you are supposed to use. With g++, this can be set by adding the -std=c++17 flag.